Venezuelans have paid an emotional farewell to the late President Hugo Chavez at his state funeral in Caracas.
Vice-President Nicolas Maduro told mourners Mr Chavez, who led Venezuela for 14 years, remained “undefeated, pure, living for all time”.
Mr Maduro was due to be sworn in as acting president later on Friday. He has to call elections within 30 days.
Opposition leader Henrique Capriles condemned Mr Maduro’s imminent inauguration as “fraudulent”.
He said that “nobody elected” Maduro president and that the government was “abusing” its powers.
Opposition parties are boycotting Mr Maduro’s swearing-in, arguing that under the constitution the speaker of the National Assembly should be the one to take over as acting president.
But, in a decision made public as the funeral went ahead, Venezuela’s Supreme Court ruled in Mr Maduro’s favour.
Hugo Chavez, 58, died on Tuesday after a two-year battle with cancer.
The vice-president began the funeral ceremony by presenting Mr Chavez’s coffin with the sword of Simon Bolivar – the 19th-Century independence leader he claimed as his inspiration.
In his eulogy, Mr Maduro said no other leader had been as vilified as Mr Chavez, but no-one had been able to stop him or his socialist “revolution”.
“The humble, the poor, the oppressed – we are his living testimony”, Mr Maduro said.
He also praised Mr Chavez’s work for Latin American unity, and said he worked for “a world without empires”.
More than 30 world leaders attended the ceremony, including Cuban President Raul Castro, Iran’s Mahmoud Ahmadinejad and Alexander Lukashenko of Belarus.
A message was read out from Syrian President Bashar al-Assad.
Honour guards were made up of prominent Venezuelans, including student leaders and baseball players, Formula One driver Pastor Maldonado and conductor Carlos Dudamel.
Mourners inside the venue chanted “Chavez did not die, he multiplied!”
Ecumenical prayers were led by three religious leaders, including the American civil rights activist, Rev Jesse Jackson, who called for reconciliation between Venezuela and the US.
“We share the same hemisphere, we play ball together, we trade resources together, we share dreams together,” he said.
Outside, huge crowds dressed in the red sang “Chavez lives!” and “The struggle continues!”
More than two million people have filed past Mr Chavez’s coffin, and his body is to be put on permanent display.
On Thursday, Mr Maduro said that Mr Chavez’s body would be embalmed “like Lenin and Mao Zedong”.
The body will be moved to the Caracas military museum where in 1992 Mr Chavez – as an army officer – was captured after leading a failed coup.
The building will be converted into a new “museum of the revolution”, Mr Maduro said.
Supporters want him eventually interred in Venezuela’s national Pantheon alongside Simon Bolivar.
However, under Venezuela’s constitution, people may only be admitted to the Pantheon 25 years after their death.
Mr Chavez, 58, was re-elected for a fourth term as president last October after saying he had recovered from his illness.
He named Mr Maduro as his preferred successor following the recurrence of his cancer.
The vice-president is to be sworn in as acting president after the funeral in a special session of the National Assembly.
Under Venezuela’s constitution, elections must be called within 30 days and the government has said it will abide by this.
Mr Maduro will be the candidate for the governing United Socialist Party (PSUV).