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 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.”
Mr Maduro had been serving as acting president since Mr Chavez died of cancer on 5 March.
He is due to be sworn in on 19 April and serve until January 2019 to complete the six-year term that Mr Chavez would have begun in January.
Mr Chavez was a divisive leader. To his supporters he was the reforming president whose idiosyncratic brand of socialism defeated the political elite and gave hope to the poorest Venezuelans.
He effectively used his country’s vast oil reserves to boost Venezuela’s international clout, and his strident criticism of the US won him many political allies in Latin America.
However, his political opponents accused him of being an autocrat, intent on building a one-party state.
Mr Chavez bequeaths a nation beset by crumbling infrastructure, unsustainable public spending and under-performing industry.