Venezuela's Hugo Chávez has once again defied his doubters by winning a new term of office in the presidential election after what had been billed as the closest race of his political life.

To the euphoria of supporters in and around his campaign headquarters, the National Electoral Council announced on Sunday the president had secured 54.4% of the votes, while his rival Capriles was behind with 44.9%. Some votes were still to be counted, but the council said the result was not in doubt.

Pumping his fist in the air, Chávez address his supporters from the balcony of the presidential palace as a barrage of fireworks lit up the sky. "The revolution has triumphed!" Chávez told the crowd, saying his supporters "voted for socialism."

"Today we've shown that Venezuela's democracy is one of the best democracies in the world, and we will continue to show it," he shouted, waving a replica of Símon Bolivar sword.

As the result was announced, his supporters burst into cheers and songs of "Viva Le Patria" and "Ooh Aah, Chávez won't go."

"I'm crying with joy," said Alirio Guevara, a fisherman from Vargas, who came to Caracas to vote and joined the joyous crowds at the Chávez campaign headquarters. "In the next six years, we will deepen the revolution."

In accepting defeat, Capriles took solace in picking up more votes than any previous challenger and restricting Chávez to a single-digit margin of victory.

"In order to win, one must know how to lose. For me the people's voices are sacred. For those who feel sad, I tell them, 'we started to build a road and there it is'. We have 6 million people who want a new road."

Underlining the intense interest in the campaign, the turnout among the 19 million registered voters was a record 80.4%.

Many analysts had warned that a slim margin of victory could lead to violence, but with an almost double-digit gap there was no immediate indication of unrest on Sunday evening.

Venezuelans had queued under the sun for up to five hours to cast their vote amid expectations of a possible change, prompted by vastly contrasting opinion surveys in the weeks before the poll.

Chávez has held on to power for more than a decade despite an attempted coup, a nationwide oil strike and a yearlong fight with cancer, which may not be over.

With many voters unhappy at one of the world's highest murder rates and crumbling infrastructure, his party had lost ground in recent legislative elections and his long illness had clearly restricted his campaign appearances, particularly in contrast to his 40-year-old rival who was making two stops a day in a energetic campaign that criss-crossed the country.

The opposition had felt this was their best chance to regain power, but the president ended strongly with a giant rally of hundreds of thousands of supporters in Caracas on the final day of the campaign on Thursday.

On the campaign trail, president Chávez vowed that if re-elected he would use the next six years to correct past mistakes, to continue to build a socialist alternative to the capitalist model, and to continue using the country's vast oil revenues to redistribute wealth, promote the revolution overseas and to bolster ideological allies such as Cuba and Nicaragua.

But analysts say his reduced margin of victory – down from 26% in 2006 and 16% in 1998 – may prompt changes in the cabinet and the government's policy, particularly with regard to public security and the economy. Health concerns are also likely to linger.