CARACAS, Venezuela — President Hugo Chávez of Venezuela died Tuesday afternoon after a long battle with cancer, the government announced, leaving behind a bitterly divided nation in the grip of a political crisis that grew more acute as he languished for weeks, silent and out of sight in hospitals in Havana and Caracas.

With his voice cracking and close to tears, Vice President Nicolás Maduro said that he and other officials had gone to the military hospital where Mr. Chávez was being treated, sequestered from the public, when “we received the hardest and most tragic information that we could transmit to our people.”

Mr. Chávez’s departure from a country he dominated for 14 years casts into doubt the future of his socialist revolution. It not only alters the political balance in Venezuela, the fourth-largest foreign oil supplier to the United States, but also in Latin America, where Mr. Chávez led a group of nations intent on reducing American influence in the region.

Mr. Chávez changed Venezuela in fundamental ways, empowering and energizing millions of poor people who had felt marginalized and excluded. But his rule also widened society’s divisions, and his death is sure to bring vast uncertainty as the nation tries to find its way without its central figure.

When a president dies, the Constitution says that the nation should “proceed to a new election” within 30 days, and that the vice president should take over in the meantime. The election is likely to pit Mr. Maduro, whom Mr. Chávez designated as his political successor, against Henrique Capriles Radonski, a young state governor who lost to Mr. Chávez in a presidential election in October.

But there has been heated debate in recent months over clashing interpretations of the constitution, in light of Mr. Chávez’s illness, and it is impossible to predict how the post-Chávez transition will proceed. Mr. Chávez was given a diagnosis of cancer in June 2011, but throughout his treatment he kept many details about his illness secret, refusing to say what kind of cancer he had or where in his body it occurred. He had three operations from June 2011 to February 2012, as well as chemotherapy and radiation treatment, but the cancer kept coming back. The surgery and most other treatments were done in Cuba.

Then on Dec. 8, just two months after winning re-election, Mr. Chávez stunned the nation by announcing in a somber televised address that he needed yet another surgery.

That operation, his fourth, took place in Havana on Dec. 11. In the aftermath, grim-faced aides described the procedure as complex and said his condition was delicate. They eventually notified the country of complications, first bleeding and then a severe lung infection and difficulty breathing.

After previous operations, Mr. Chávez often appeared on television while recuperating in Havana, posted messages on Twitter or was heard on telephone calls made to television programs on a government station. But after his December surgery, he was not seen again in public, and his voice fell silent.

Mr. Chávez’s aides eventually announced that a tube had been inserted in his trachea to help his breathing, and that as a result he had difficulty speaking. It was the ultimate paradox for a man who seemed never at a loss for words, often improvising for hours at a time on television, haranguing, singing, lecturing, reciting poetry and orating.

As the weeks dragged on, tensions rose in Venezuela, and the situation turned increasingly bizarre. Officials in Mr. Chávez’s government strove to project an image of business as usual and deflected inevitable questions about a vacuum at the top. At the same time, the country struggled with an out-of-balance economy, troubled by soaring prices and escalating shortages of basic goods.

The opposition, weakened after defeats in the presidential election in October and elections for governor in December, in which its candidates lost in 20 of 23 states, sought to keep pressure on the government.

Then officials suddenly announced on Feb. 18 that Mr. Chávez had returned to Caracas. He arrived unseen on a predawn flight and was installed in a military hospital, where aides said he was continuing treatments.

Over nearly a decade and a half, Mr. Chávez built a political movement and a government that were centered on his outsize personality. He made most major decisions and dominated all aspects of political life. He inspired a fierce, sometimes religious devotion among his supporters and an equally fervent animus among his opponents. As many of his followers say: “With Chávez everything, without Chávez nothing.”

But that leaves his revolution in a precarious spot without its charismatic leader.

“In regimes that are so person-based, the moment that the person on which everything hangs is removed, the entire foundation becomes very weak because there was nothing else supporting this other than this figure,” said Javier Corrales, a professor of political science at Amherst College.

Mr. Chávez’s death could provide an opportunity for the political opposition, which was never able to defeat him in a head-to-head contest.

Mr. Capriles lost by 11 percentage points to Mr. Chávez in October. But he has twice beaten top Chávez lieutenants in running for governor of his state, Miranda, which includes part of Caracas.

And Mr. Maduro is far from having Mr. Chávez’s visceral connection to the masses of Venezuela’s poor. Even so, most analysts believe that Mr. Maduro will have an advantage, and that he will receive a surge of support if the vote occurs soon after the president’s death.

But even if Mr. Maduro prevails, he may have a hard time holding together Mr. Chávez’s movement and furthering its socialist goals while fending off resistance from what is likely to be a revived opposition.

Mr. Chávez’s new six-year term began on Jan. 10, with the president incommunicado in Havana. In his absence, the government held a huge rally in the center of Caracas, where thousands of his followers raised their hands to pledge an oath of “absolute loyalty” to their commander and his revolution. Officials promised that Mr. Chávez would have his inauguration later, when he had recovered.

But the hoped-for recovery never came. Now, instead of an inauguration, Mr. Chávez’s followers are left to plan a funeral.