Most Latin American leaders as well as Iran's president Mahmoud Ahmadinejad attended the ceremony in the capital Caracas.
A state funeral has taken place for Venezuela's left-wing president Hugo Chavez at a military academy where his body has been lying in state since Wednesday.
Most Latin American leaders attended the service, including Chilean president Sebastian Pinera and Cuba's Raul Castro, as well as Iran's Mahmoud Ahmadinejad and Alexander Lukashenko of Belarus.
Mr Ahmadinejad and Mr Lukashenko sat next to each other, reportedly wiping away tears as a band played one of Mr Chavez's favourite sentimental songs.
The Iranian leader earlier said: "It is a great pain for us because we have lost a friend. I feel like I have lost myself, but I am sure that he still lives.
"Chavez will never die. His spirit and soul live on in each of our hearts."
Venezuelan conductor and Los Angeles Philharmonic maestro Gustavo Dudamel led an orchestra's rendition of the national anthem to open the ceremony.
The red beret that became a symbol of his socialist rule
Mr Chavez's political heir, vice president Nicolas Maduro, placed a replica of the golden sword of South American independence hero Simon Bolivar on his mentor's wooden coffin as more than 30 heads of state applauded.
Several Latin American leaders, including Mr Castro, were invited to stand around the coffin, which was closed and covered in the yellow, blue and red colours of Venezuela, in an honour guard.
Gregory Meeks, a New York Democrat congressman, and ex-congressman William Delahunt, a Democrat from Massachusetts, represented the United States, which Mr Chavez often portrayed as a great global evil even as he sent the country billions of dollars in oil each year.
Hollywood actor Sean Penn was also among those who attended the funeral.
Nicolas Maduro, who has been sworn in as acting president
An estimated two million people have filed past Mr Chavez's coffin to say goodbye to the man worshipped by the country's poor, who he championed.
He was dressed in olive green military fatigues, a black tie and the iconic red beret that became a symbol of his 14-year socialist rule.
People blew kisses, made the sign of the cross or gave military salutes as they walked by, with just seconds to see him. Outside the academy, the line to see the body stretched for more than a mile.
His mother, Elena Frias, was pictured weeping ahead of the funeral in the capital Caracas.
Mr Chavez, a former paratrooper who died on Tuesday aged 58 after a long battle with cancer, had not been seen in public since a fourth round of surgery in Cuba in December last year.
He will lie in state for another week to allow everybody to see him, and he will then be embalmed "like Ho Chi Minh, Lenin and Mao" and kept in a glass coffin "for eternity," Mr Maduro said.
Mr Chavez's mother Elena Frias mourns her son
His remains will be displayed at the Museum of the Revolution, close to the Presidential Palace where he ruled, so that "his people will always have him", Mr Maduro said.
Mr Chavez used the former military barracks to plot a failed coup against President Carlos Andres Perez in 1992. His arrest turned him into a hero, leading to his 1998 election victory.
Mr Maduro suggested that Mr Chavez may one day be moved elsewhere, a nod to popular pressure for him to be taken to the national pantheon to lie alongside Simon Bolivar.
In a country divided by Mr Chavez's populist style, opinions of his legacy vary, with opposition supporters in better-off areas angry at the high murder and inflation rate.
Under Mr Chavez, Venezuela's oil wealth underwrote the Castro brothers' communist rule in Cuba, and he repeatedly courted confrontation with Washington by cosying up to anti-western governments in Russia, Syria and Iran.
General Jose Ornella, who said he was with Mr Chavez in his final moments, said he had suffered a massive heart attack.
"He couldn't speak but he said it with his lips, 'I don't want to die. Please don't let me die,' because he loved his country, he sacrificed himself for his country."
Although Mr Maduro is acting president, elections are expected to be called within 30 days.