VENEZUELAN President Hugo Chavez has won re-election, surviving his closest race yet.

The victory came after a bitter campaign in which the opposition accused him of unfairly using the country's oil wealth and his near total control of state institutions to his advantage.

After a long wait for the results, fireworks exploded over Caracas amid a cacophony of horn-honking by elated Chavez supporters waving flags and jumping for joy outside the presidential palace.

With 90% of votes counted, Mr Chavez had more than 54% of the vote to 45% for challenger Henrique Capriles, an athletic 40-year-old former state governor who unified and energised the opposition while barnstorming across the oil-exporting nation.

However, Mr Capriles's promises to address violent crime, streamline a patronage-bloated bureaucracy and end corruption proved inadequate against Mr Chavez's charisma, well-oiled political machine and a legacy of putting the poor first with generous social welfare programmes.

Mr Chavez rallied thousands of supporters from a balcony of the presidential palace, holding up a sword that once belonged to 19th-century independence hero Simon Bolivar.

"The revolution has triumphed," Mr Chavez told the crowd, saying his supporters "voted for socialism".

The crowd responded, chanting: "Chavez won't go!"

Mr Chavez will now have a freer hand to push for an even bigger state role in the economy and continue populist programmes.

He pledged before the vote to make a stronger push for socialism in the next term.

He is also likely to further limit dissent and deepen friendships with US rivals.

A Capriles victory would have brought a radical foreign policy shift including a halt to preferential oil deals with allies such as Cuba, along with a loosening of state economic controls and an increase in private investment.

It was Mr Chavez's third re-election in nearly 14 years in office. It was also his smallest victory margin. In 2006, he won by 27%.

Construction worker Edgar Gonzalez said: "I can't describe the relief and happiness I feel right now.

"The revolution will continue, thanks to God and the people of this great country".

Voter turnout was an impressive 81%, compared to 75% in 2006.

Mr Chavez paid close attention to his military-style get-out-the-vote organisation at the grassroots, stressing its importance at campaign rallies.

However, the opposition said he unfairly put millions in state funds into the effort.

The President spent heavily in the months before the vote, building public housing and bankrolling expanded social programmes.

Mr Chavez spoke little during the campaign about his fight with cancer, which since June 2011 has included surgery to remove tumours from his pelvic region as well as chemotherapy and radiation treatment.

He has said that his most recent tests showed no sign of illness.

Mr Capriles told supporters not to feel defeated.

He said: "We have planted many seeds across Venezuela and I know these seeds are going to produce many trees."

But despite winning a February primary that unified the opposition, Mr Capriles proved no match for Mr Chavez's electoral prowess.