Iran’s President Mahmoud Ahmadinejad, center, and Belarus’ President Alexander Lukashenko, at left with his son Nikolai, stand next to the coffin of the late Venezuela’s President Hugo Chavez during the funeral ceremony in Caracas, Venezuela, on Friday.

CARACAS, Venezuela — With folk songs, a soaring choir and the brandishing of a symbolic sword, Venezuela bade goodbye to President Hugo Chavez in an emotional funeral Friday as his hand-picked successor pledged to fiercely defend his socialist revolution.

The ceremony drew world leaders, athletes and left-wing celebrities, while multitudes of Chavez supporters watched on giant screens outside. The day was set to end with the swearing-in of Vice President Nicolas Maduro as interim president, despite criticism from opposition leaders that the move is unconstitutional.

The funeral launched with Venezuela’s national youth orchestra singing the national anthem, led by famed conductor Gustavo Dudamel. A government-allied congressman later belted out cowboy songs from Chavez’s native Barinas state.

With much of the world watching, Maduro delivered a fiery speech repeating some of the aggressive rhetoric he had used just hours before announcing Chavez’s death Tuesday.

His words, and even the tone of his voice, echoed the speeches that Chavez so often delivered, even if the crowds of red-shirted supporters this time were kept far away from the ceremonies held in a military academy.

“We have smashed the curse of betrayal of the country and we will smash the curse of defeat and regression, Maduro shouted, his voice breaking, and in tears.

Maduro also reached out to the United States, which he had accused of giving Chavez cancer just three days before.

“We love all the people of our America, but we want relations of respect, of cooperation, of true peace,” Maduro said. “We want ... a world without empires, without hegemonic nations, a world of peace that respects international law.”

More than 30 political leaders including Cuba’s Raul Castro and Iran’s Mahmoud Ahmadinejad stood at attention before Chavez’s flag-draped coffin, and the guest list in large part reflected Chavez’s foreign policy of strident criticism of the U.S. and friendships with nations at odds with Washington.

The United States was represented by Rep. Gregory Meeks, a New York Democrat, and former Rep. William Delahunt, a Democrat from Massachusetts.

The Rev. Jesse Jackson delivered a short sermon, preaching rapprochement between his country and Venezuela.

“Venezuela is not alone,” Jackson said. “With Maduro, grant him wisdom and support as he keeps hopes and dreams alive, as he picks up the baton and makes a great nation greater. We pray God today that you will heal the breach between the U.S. and Venezuela.”

More conservative leaders from nearby nations also joined the funeral, including Colombian President Juan Manuel Santos and Chilean President Sebastian Pinera.

Ahmadinejad won one of the biggest rounds of applause of leaders entering the funeral.

“It is a great pain for us because we have lost a friend,” Ahmadinejad said upon his arrival at the airport the night before. “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.”

At the end of the funeral, Maduro handed a replica of Simon Bolivar’s sword to the family of Chavez, who had modeled himself on the independence hero and even added “The Bolivarian Republic” to the nation’s name.

On Thursday, the acting leader announced the government would embalm Chavez’s body and put it on permanent display, a decision that touched off strong passions on both sides of this deeply divided country, which Chavez ruled for 14 years before succumbing to cancer at the age of 58.

Most of the normally traffic-choked streets of Caracas were empty, with schools and many businesses shuttered. The government also prohibited alcohol sales. Many Venezuelans, particularly Chavez supporters, said they were caught up in the pomp and circumstance of the past few days, and flattered to be the subject of world’s attention.

“This is historic ...I have never seen anything like it,” said Edila Ojeda, a 57-year-old janitor. “He was a world leader recognized internationally. I am speechless. It is impressive.”

Others said they were put off by what they saw as excess, particularly the plan to put Chavez’s body on display.

“He was a president, and I would say not a good one. Not a hero,” said Gloria Ocampos, a retired office manager. “He should be buried, just like any other president. They are treating him like he was the father of the country ... It’s crazy.”

Following the funeral, National Assembly Speaker Diosdado Cabello was to swear in Maduro as interim president at the same military academy complex where Chavez’s body is lying in state. Normally, presidents in Venezuela are sworn in at the National Assembly.

In announcing the opposition boycott of the swearing-in, spokesman Angel Medina said that Maduro’s ascension is “a violation of the constitutional order.”

“Venezuelans should walk along the path of constitutionality. Today, more than ever we reject that they use the name of the president of the republic, who today is being buried, for political ends,” he said. Critics believe Venezuela’s 1999 charter stipulates that the speaker of the National Assembly take power in the event of a presidential death.

The constitution says elections must be held within 30 days of Chavez’s March 5 death, though the government has not set a date. Maduro has announced he will be the candidate of Chavez’s ruling socialist party against likely opposition candidate Henrique Capriles, and many expect him to ride the wave of emotion following Chavez’s death to victory.

For many Chavez supporters, and the political insiders he left behind, the task ahead will be continuing the president’s political movement beyond his death.

Maduro announced Thursday that the late president’s body will be embalmed and forever displayed inside a glass tomb at a military museum not far from the presidential palace from which he ruled. Analysts said the perpetual display was meant to keep Chavez’s power structure alive, long after his death at age 58.

“Nicolas Maduro and his government are building an aura that makes it very difficult, I would say, that in the future, the opposition tries to promote an alternative to the government,” said Oscar Valles, a political analyst at the Metropolitan University in Caracas.

Heart-broken supporters were clearly in favor of the effort.

“We must think about the future and how we are going to guarantee the continuity of the revolution,” said Rolando Tarazon, a street vendor who was waiting with his wife to see Chavez’s late Thursday.

Chavez was particularly beloved by the poor, whose lot he championed. But critics say he left his successors a monumental task, with inflation of more than 20 percent a year, and public debt quadrupling to more than $100 billion. Crime is endemic and Chavez’s chaotic management style has been blamed for a breakdown in infrastructure, particularly in the key oil industry.

Yet for some lined up to see Chavez’s body early Friday, the road ahead meant keeping the late leader’s legacy alive.