Dilma Rousseff of the Workers Party has been re-elected Brazil's president in what was one of the most closely contested elections in the country.

Rousseff won 51.6% of votes in a runoff against Brazilian Social Democracy Party's Aecio Neves, who won 48.4% with more than 99% of the votes tallied, reports Reuters.

The election that saw the country split along the lines of social class and geography now extends for four years the rule of the Workers Party, in power since 2002.

The party has been credited with transforming Brazil through many welfare programmes for the poor and minorities, lifting 40 million from poverty, tackling unemployment and hunger.

Rousseff owes her victory to overwhelming support from the poor who have benefited from her party's social security programme and housing schemes, besides government-sponsored vocational schools and credit expansion to the working class.

On winning the polls, Rousseff said she wanted to be "a much better president than I have been until now".

Voting was largely peaceful.

Neves conceded defeat in a speech to supporters in the southern city of Belo Horizonte.

Both he and Rousseff had made economic growth and poverty alleviation central to their campaigns, reports the BBC.

Rouseff has the immediate task of addressing the economic slump and a possible credit downgrade unless she makes hefty spending cuts to correct deficits.

The economy is believed to have slowed dramatically under Rousseff's interventionist policies. International markets are nervous about the high level of government intervention in the economy.

Rousseff, who is the country's first woman president, came to the limelight in the 70s when she was jailed and tortured for opposing the military dictatorship.

Daughter of a Bulgarian aristocrat who emigrated to Brazil during World War Two, Rouseff was handpicked by Luiz Inacio Lula da Silva as his successor.