Mr. Hugo Chavez, the swashbuckling president of Venezuela, has died. He will be missed by the millions of Venezuelans who benefited from his largess as well as by world leaders who delighted in antagonizing the United States and like-minded governments.

It would be tempting to call Mr. Chavez a 21st-century jester, but he was much more than that: He was a shrewd politician with a deft touch, who may have had good intentions but also embraced a dangerous agenda.

A former altar boy with a love for baseball, Mr. Chavez enrolled in the Military Academy of Venezuela and then moved to the parachute corps of the army, eventually reaching the rank of lieutenant colonel.

On Feb. 4, 1992, he led a failed military coup against then President Carlos Andres Perez, an act of insurrection that won him two years in jail before he was granted amnesty. Upon his release, he formed a political party, the Fifth Republic Movement, which he rode to victory in the 1998 presidential campaign.

His campaign was populist in nature. He denounced corruption, poverty and his country’s wealthy. It was fertile soil for his political maneuvers: Venezuela’s per capita income had fallen nearly in half in seven years. Poverty levels had increased more than 17 percent and crime rates had doubled.

After winning election, he quickly consolidated his support, using the country’s oil revenues to open free health clinics and expand social programs, and passing a constitution that established the right to education, housing, health care and food.

Slowly but surely he abandoned capitalism until he declared that “the path to a new, better and possible world is not capitalism. The path is socialism.”

With that goal in mind, he set about to construct a Bolivarian Revolution, named after his hero Simon Bolivar, another swashbuckler who was instrumental in helping South American nations win their independence nearly two centuries ago. Using Venezuela’s extensive oil reserves — some reckon that at 500 billion barrels, they might be the largest in the world — Mr. Chavez extended assistance and aid to like-minded leaders and governments around the world.

Among his close friends and allies were Messrs. Fidel and Raoul Castro of Cuba, Bolivia’s President Evo Morales, Mr. Rafael Correa of Ecuador and Mr. Daniel Ortega, president of Nicaragua. All were avowed leftists and communists who, like Chavez, saw the U.S. as their enemy.

While they all shared his outlook, few had his gift for speaking. Once when addressing the United Nations General Assembly after U.S. President George W. Bush, Mr. Chavez noted that he could still smell the sulfur at the podium. There was no love lost between the two men. When Mr. Chavez was briefly overthrown by a coup in 2002, Mr. Bush’s government remained silent and even went so far as to recognize the new leader, despite the U.S. president’s professed respect for democracy.

That coup failed and Mr. Chavez returned to office within 48 hours, but he was changed by the incident. From that point on, Mr. Chavez took a sharp leftward turn — he could have been characterized as a social democrat until that point — and consolidated power around him.

He gathered as much power as possible in the executive and then ensured that loyalists controlled the institutions — the military and the judiciary — that remained beyond his grasp. He used the courts to go after his enemies and limit challenges to his power. Human Rights Watch condemned Mr. Chavez for openly endorsing and embracing official acts of discrimination.

For all his excesses, though, Mr. Chavez ultimately ruled because a majority of Venezuelans supported him. After his first victory in 1998, he won re-election in 2000, survived a recall election in 2004, claimed another six-year term in 2006, and a fourth term last October. But he was not to enjoy the final victory.

Mr. Chavez had the first of four operations in June 2011. The uncharacteristic silence about his condition was probably the best indication that something was seriously wrong. Proxies and supporters declared him healthy, while Mr. Chavez himself remained out of sight. Eventually he conceded that he had cancer but said it would be beaten. He succumbed this week to a respiratory infection brought on by his treatment.

Venezuelans now face two questions: Who will succeed Mr. Chavez, and will Mr. Chavez’s Bolivarian Revolution outlive its creator?

Vice President Nicolas Maduro was Mr. Chavez’s choice, but there are doubts about whether he has the charisma or the capability to rally the poor or bridge the deep divides not only in the whole Venezuela but also within the nation’s left.

As for the second question, Venezuela is wealthy enough to support a functioning welfare state and perhaps even to continue the generosity that Mr. Chavez showered on friends and allies. But returns on Mr. Chavez’s policies were dwindling.

Oil revenues provided 90 percent of Venezuela’s currency inflows; 50 percent of government revenues come from the petroleum industry, mostly from the state oil company. Monies are not being reinvested in crumbling infrastructure but handed out as campaign gifts or in some cases stolen — corruption is rife.

The World Bank forecasts the economy to slow to 1.8 percent growth in 2013, although many private analysts anticipate a recession. A slowing economy, a divided country and a concentration of power in the executive is a dangerous combination.

For all his dreams, Mr. Chavez has left his country a dangerous legacy.