Socialist Nicolas Maduro, hand-picked successor of the late leader Hugo Chavez, has won a narrow victory in Venezuela’s presidential poll.
Mr Maduro won 50.7% of the vote against 49.1% for opposition candidate Henrique Capriles.
Mr Capriles has demanded a recount, saying Mr Maduro was now “even more loaded with illegitimacy”.
He said there were more than 300,000 incidents from Sunday’s poll that would need to be examined.
The waiting was long and tense. Rumours on Twitter were growing. Both sides were cautious, but fireworks were going off all around the city.
Even in front of the Miraflores presidential palace there was uncertainty. People started gathering early on in the night, but they listened to radios to keep across the official results.
The National Electoral Council’s announcement was broadcast through loudspeakers among the crowd, but people didn’t wait to hear the margin by which Nicolas Maduro had won.
Screaming and chanting took over. Beer was thrown into the air. People hugged each other. Nobody seemed to mind if the victory was narrow. “This victory is dedicated to Hugo Chavez, our commander. My vote went to him,” said one woman.
The electoral commission said the results were “irreversible”.
When the results were announced at 23:15 (03:45 GMT), celebrations erupted in the capital, Caracas, where Mr Maduro’s jubilant supporters set off fireworks and blasted car horns. Opposition voters banged pots and pans in protest.
In a victory speech outside the presidential palace, Mr Maduro, wearing the colours of the Venezuelan flag, told crowds that the result was “just, legal and constitutional”.
He said his election showed Hugo Chavez “continues to be invincible, that he continues to win battles”.
Mr Maduro said he had spoken to Mr Capriles on the phone, and that he would allow an audit of the election result.
He called for those who had not voted for him to “work together” for the country.
But Mr Maduro’s margin of victory was far narrower than that achieved by Chavez at elections last October, when he beat Mr Capriles by more than 10%.
At Mr Capriles’ campaign headquarters the mood was sombre, as his supporters watched the results on television. Some cried, while others hung their heads in dismay,
Shortly afterwards, Mr Capriles emerged, angry and defiant.
“It is the government that has been defeated,” he said. Then, addressing Mr Maduro directly, he said: “The biggest loser today is you. The people don’t love you.”