Rousseff, Brazil's first woman president, went into the run-off contest as slight favorite and defeated center-right challenger Aecio Neves by around three million votes.
With 99 percent of votes counted, she had won a 51.52 percent vote share to 48.48 percent to Neves, the business world favorite.
"Thankyou very much," Rousseff, 66, tweeted as it became clear she had won.
The race to lead the world's seventh-largest economy was seen as a referendum on 12 years of government by the Workers' Party (PT) -- eight under working-class hero Luiz Inacio Lula da Silva and four under Rousseff, with voters weighing the PT's social legacy against Neves's promise of economic revival.
The bitterness of the campaign, the most vitriolic since democracy was restored in 1985 after two decades of military rule, threatens to leave the country sorely divided.
The PT endeared itself to the masses with landmark social programs that have lifted millions from poverty, increased wages and brought unemployment to a record-low 4.9 percent.
But the outlook has darkened since Rousseff first took office in 2010, the year economic growth peaked at 7.5 percent.
She has presided over rising inflation and a recession this year, amid protests against corruption, record spending on the World Cup and poor public education, health care and transport.
- 'More equal' Brazil -=======================
Neves vowed to reboot the economy with market-friendly policies while safeguarding the PT's social programs.
But Rousseff's supporters cast him as a fat cat who will govern for the upper class and that view looked to have prevailed, Mark Weisbrot of the US Center for Economic and Policy Research told AFP, saying Neves' more liberal plans would not have guaranteed badly needed investment.
"It may seem like 'the markets' are demanding such things, but if they ever got them, they would not react well at all," said Weisbrot, citing the experience of the Eurozone, where "the markets" had demanded austerity.
"The resulting triple-dip recession did not attract investment -- rather it repelled investment," Weisbrot said.
Rousseff cast her ballot in Porto Alegre, the southern city where she grew up.
"We are voting for a more equal Brazil with more opportunities," Rousseff said.
Neves, 54, gave V for victory signs as he cast his ballot in Belo Horizonte, where he served two terms as governor of Minas Gerais state, insisting that "change has already begun."
- Corruption issue -====================
Despite support for her social policies, Rousseff has been hit by corruption scandals, especially a multi-billion-dollar embezzlement scheme implicating dozens of politicians -- mainly her allies -- at state-owned oil giant Petrobras.
As the fiery campaign wrapped up, conservative news magazine Veja quoted a suspect in the case as saying Rousseff and Lula personally knew of the scam -- a claim the president vehemently denied.
But the issue will dog her, said independent consultant Andre Cesar.
"
If the allegations are confirmed that could spark a political crisis," Cesar told AFP.
The graft issue swayed some, but not others.
"I am voting for Neves. We are fed up with corruption scandals," Roberto Carlos da Silva, a 34-year-old doctor in a chic Sao Paulo suburb, told AFP.
But civil servant Maria de Fatima de Oliveira Borges from Brasilia said: "I'm voting for the PT because I believe in its project of social change."
The campaign has been a fierce battle for Rousseff, a former guerrilla once jailed and tortured for fighting the country's 1964-1985 military regime.
First, she had to fend off environmentalist Marina Silva, who exited the first round three weeks ago with 21 percent of the vote to 42 percent for Rousseff and 34 percent for Neves.
Silva then endorsed Neves, whose comeback briefly lifted him into first place -- and prompted a furious Rousseff counter-attack.
She accused Neves of nepotism as Minas Gerais governor and played up a report that he once hit his then-girlfriend in public.
Neves, the grandson of the man elected Brazil's first post-dictatorship president, responded by accusing Rousseff of lying and "collusion" in the Petrobras kickbacks.
As well as their president, voters also elected governors in run-offs in 14 states, with Luiz Fernando Pezao of the Brazilian Democratic Movement Party (PMDB) -- a Rousseff coalition ally -- winning in Rio de Janeiro.
Nationwide 281 people were arrested for election-related "irregularities" -- one for taking a "selfie" in the poll booth in Sao Paulo state, while two buses were set on fire in the same state.