CARACAS (Reuters) - From Iranian President Mahmoud Ahmadinejad to U.S. Oscar-winner Sean Penn, an eclectic mix of mourners bid farewell on Friday to Venezuela's Hugo Chavez at the funeral for the charismatic but divisive leader who changed the face of South American politics.
Chavez died this week at age 58 after a two-year battle with cancer, devastating millions of mostly poor supporters who hailed him for ploughing the country's vast oil wealth into social projects, but giving hope to foes who decried him as a dictator.
A frequent visitor to Caracas and fellow "anti-imperialist," Ahmadinejad received a standing ovation as he took his place in a guard of honour by Chavez's coffin, then broke protocol to touch the casket and clench his fist in a revolutionary salute.
"Commander, here you are undefeated, pure, living for all time," Chavez's preferred successor, acting President Nicolas Maduro, said over the casket, his voice cracking with emotion.
"Your soul and spirit are so powerful that your body could not hold them, and now they are travelling this universe, growing with blessings and love."
The mourners chanted: "Chavez lives! The fight continues!"
Maduro, who was due to be sworn in as caretaker president on Friday, laid a replica of the sword of 19th century independence leader Simon Bolivar on top of the coffin, which was draped in the country's red, yellow and blue flag.
A singer in a cowboy hat serenaded the mourners with folk music from Chavez's birthplace in Venezuela's "llanos" plains.
The late president's body was to be embalmed and shown "for eternity" - similar to how Communist leaders Lenin, Stalin and Mao were treated after their deaths.
His remains will lie in state for an extra seven days to accommodate the millions of Venezuelans who still want to pay their last respects to a man who will be remembered as one of the world's most colourful and controversial populist leaders.
Huge crowds of "Chavistas" gathered from before dawn for the ceremony at a military academy where his body was lying in state. Many were dressed in the red of the ruling Socialist Party, carrying his picture and waving Venezuelan flags.
"SO MUCH PAIN"
"There are no words for so much pain," said 30-year-old Kimberly Garcia, sobbing uncontrollably. "Comandante, you are our sky, our sun, our life. Thanks to you, we have a homeland."
Some fans waited for more than 26 hours to view Chavez's coffin. More than 2 million people have filed past the casket since Wednesday, many in tears, some saluting, and others crossing themselves.
In Caracas were most of Chavez's highest-profile Latin American friends, such as Ecuadorean President Rafael Correa and Brazil's former leader, Luiz Inacio Lula da Silva.
Underscoring Chavez's talent for uniting a mix of perhaps unlikely allies, the centre-right presidents of Chile and Colombia attended, as well as Western idealists like actor Penn and U.S. civil rights leader Rev. Jesse Jackson, who read a prayer.
As the funeral took place, indigenous priests in Bolivia, a close leftist ally, made offerings to 'mother earth' in Chavez's honour.
"He was invincible. He left victorious and no one can take that away. It is fixed in history," Cuban President Raul Castro said, referring to Chavez's four presidential election wins, among a string of other ballot victories in his 14-year rule.
The Castro's were very close Chavez allies. Chavez regarded Fidel Castro as a mentor and father figure, and his country's oil and investments helped keep the island nation's economy afloat.
Renowned conductor Gustavo Dudamel, who heads Venezuela's Simon Bolivar Symphony Orchestra and the Los Angeles Philharmonic, led musicians at the funeral playing classical numbers and the national anthem.
Belarusian President Alexander Lukashenko and Ahmadinejad were among the more controversial figures present. Ahmadinejad has caused a storm back home for saying Chavez would be resurrected alongside Jesus Christ and a "hidden" imam who Shi'ite Muslims believe will rise up to bring world peace.
The United States did not send senior officials to honour Chavez, who famously derided George W. Bush as "the devil" and championed international pariahs like Ahmadinejad, Libya's late Muammar Gaddafi and Syrian President Bashar al-Assad.
Former U.S. Representative William Delahunt and U.S. Representative Gregory Meeks were attending, amid speculation of a possible post-Chavez rapprochement between ideological foes.
A government source said Chavez slipped into a coma on Monday before dying the following day of respiratory failure. The cancer had spread to his lungs, the source added.
Chavez never said what type of cancer he was suffering, and for privacy, chose to be mainly treated in Cuba.
His death paved the way for a new election in the OPEC nation that boasts the world's biggest oil reserves. But it is unclear when the vote will be held.
At the gates of the academy, activists handed out photos of Chavez along with printed quotes of his call for supporters to vote for Maduro should anything happen to him.
The constitution stipulates that an election must be called within 30 days, but politicians say the electoral authorities may not be ready and there has been talk of a possible delay. Foreign Minister Elias Jaua said the election date may be announced in the coming hours.
Maduro, 50, a former bus driver who became foreign minister and then vice president, looks certain to face opposition leader Henrique Capriles, 40, the centrist governor of Miranda state who lost to Chavez in October's election.
The Supreme Court ruled on Friday that Maduro would not have to step down to campaign. Capriles called the decision a "constitutional fraud."
Opposition sources say the 30 or so political groupings making up the Democratic Unity coalition have again agreed to back Capriles, whose 44 percent vote share in 2012 was the best performance by any candidate against Chavez.
Contrasting with the outpouring of grief at the funeral, senior opposition figure Leopoldo Lopez cautioned that the post-Chavez era would not automatically bring a brighter future.
"The uncertainty goes on, as does the gross meddling by Cuba and the flagrant violation of the constitution. Our people continue to be overwhelmed by insecurity, inflation and food shortages," he said.
Two recent opinion polls gave Maduro a strong lead over Capriles, and Western investors and foreign diplomats are factoring in a probable win for Maduro and a continuation of "Chavista" policies, at least in the short term.
The latest survey, by respected local pollster Datanalisis, gave Maduro 46.4 percent versus 34.3 percent for Capriles. It was carried out on in mid-February, before Chavez's death.
(Additional reporting by Andrew Cawthorne, Deisy Buitrago, Marianna Parraga, Pablo Garibian, Simon Gardner and Girish Gupta in Caracas, Rosa Tania Valdés in Havana and Carlos Quiroga in La Paz; editing by Jackie Frank)