More than 30 heads of state paid tribute to the leftist firebrand president as his body lay in state in a flag-covered coffin at a military academy, bringing the curtain down on a 14-year reign that divided his nation.
"There you are, undefeated, pure, transparent, unique, true, alive forever," his political heir, Nicolas Maduro, said in a 30-minute tribute that both praised his mentor and railed against the "insults" of his opponents.
"Mission accomplished comandante! The struggle goes on," said Maduro, the vice president due to be sworn in as acting president later Friday.
But the opposition will boycott the inauguration, setting the stage for a bitter election campaign, five months after Chavez defeated a stronger challenger than usual, Henrique Capriles, who will likely face Maduro this time.
Lawmaker Angel Medina of the Democratic Union Roundtable, an umbrella grouping of opposition parties, branded the hasty swearing-in "another electoral act and a violation of the Venezuelan constitutional order."
Venezuela is giving Chavez a long farewell, with hundreds of thousands of people filing past his open casket nonstop since Wednesday. Some fainted from the heat, many spent the night outside to see the man who became a hero of the poor with oil-funded social programs.
Venezuelan conductor and Los Angeles Philharmonic maestro Gustavo Dudamel led an orchestra's rendition of the national anthem to open the state funeral.
Maduro placed a replica of the golden sword of South American independence hero Simon Bolivar on his mentor's wooden casket and then handed it to his family at the end of the funeral.
Presidents Mahmoud Ahmadinejad of Iran and Alexander Lukashenko of Belarus sat next to each other, wiping away tears as a band played one of Chavez's favorite sentimental songs, typical from his native land.
Several Latin American leaders, including Cuban President Raul Castro, were invited to stand around the coffin, which was closed and covered in the yellow, blue and red colors of Venezuela, in an honor guard.
As well as alliances with a motley crew of anti-Western autocrats, Chavez had also built friendships with some Hollywood stars, including Oscar-winning actor Sean Penn, who attended the funeral.
Chavez's body will lie in state for seven more days and officials said his body will be embalmed and preserved "like Lenin" to rest in a glass casket in the military barracks where he plotted a failed coup in 1992.
Foreign Minister Elias Jaua and a crowd of flag-waving Chavez supporters greeted leaders as they arrived at the military academy for the funeral. The crowd chanted "Chavez lives, the struggle goes on!"
Ahmadinejad, looking emotional, hugged Jaua and pumped both fists in the air toward the Chavez loyalists.
When he had landed early Friday, the Iranian leader, whose nation's nuclear program has it locked in a diplomatic stand-off with the West, said "Chavez will never die, his soul and spirit are alive in the hearts of fighters."
Lukashenko, who has ruled Belarus for 18 years with such little tolerance of dissent that he was once dubbed "Europe's last dictator" by the United States, smiled and also pumped his left fist at the crowd.
Castro, whose nation's economy relies on cheap Venezuelan oil shipments to stay afloat, waved both hands and then held them together.
Leaders from Africa and the Caribbean attended the funeral but European nations sent lower-level delegations while the United States was represented by its charge d'affaires and two Democratic Party politicians.
Despite testy ties, Maduro welcomed US Representative Gregory Meeks of New York and former congressman Bill Delahunt of Massachusetts, who were sent by President Barack Obama to the ceremony.
"We love all people of the Americas. But we want relations of respect, of cooperation, of true peace," he said, calling for world "without empires."
Under Chavez, Venezuela's oil wealth underwrote the Castro brothers' communist rule in Cuba, and he repeatedly courted confrontation with Washington by cozying up to governments who shared his "anti-imperialist" worldview.
Maduro said Thursday the body will be taken to the "Mountain Barracks" in the "January 23", a public housing project that was a bastion of Chavez support. The barracks is to be converted into a Museum of the Revolution.
It was there that Chavez spearheaded what proved to be a failed coup against then-President Carlos Andres Perez on February 4, 1992. His arrest turned him into a hero and led to his first of many election victories in 1998.
But Maduro also suggested that Chavez may one day be moved elsewhere, a nod to popular pressure for him to be taken to the national pantheon to lie alongside Bolivar.
The government said more than two million people had come since Wednesday to get a glimpse of their hero. Many stood in line through the night.
"It doesn't matter how many hours we wait. We will be here until we see him," said Luis Herrera, 49, a driver wearing a red beret who was in line with countless others in the middle of the night.
For the public viewing, Chavez was in a half-open, glass-covered casket in the academy's hall, wearing olive green military fatigues, a black tie and the iconic red beret that became a symbol of his 14-year socialist rule.
People blew him kisses, made the sign of the cross or gave military salutes as they walked by. A four-man honor guard and four tall candelabras flanked the coffin, with a golden sword at the foot of it.
In a country divided by Chavez's populist style, opinions of his legacy vary, with opposition supporters in better-off neighborhoods angry at the runaway homicide rate, high inflation and expropriations.