Gen. Vladimir Padrino, center, Venezuela's defense minister, at news conference Thursday in Caracas. (Carlos Becerra/Bloomberg News)

As Venezuela has plunged into chaos, President Nicolás Maduro has lost the support of the public as well as most Western countries. Now the powerful Venezuelan military may hold the key to whether he stays in power.

Opposition leader Juan Guaidó, who declared himself the legitimate president on Wednesday — and quickly won the recognition of the United States and much of Latin America — has been appealing to the military to abandon Maduro.

“I want to insist, to our military family, our brothers, the moment has arrived for you to put yourselves on the side of the constitution,” Guaidó, the president of the opposition-controlled National Assembly, said in a news conference Friday. He has pledged amnesty for officers who work to restore democracy.

Until recently, the idea that the military might soften its support for the socialist system founded by former president Hugo Chávez seemed ludicrous. And military leaders have shown no sign in recent days they are abandoning Maduro. But some analysts said there are subtle indications that the armed forces may, for the first time, be reconsidering their ironclad support for the socialist project that has left Venezuela in economic ruin.

“What I think we are seeing is a security [system] and armed forces that are still trying to figure out where they are on this issue,” said William Brownfield, a former U.S. ambassador to Venezuela who is now a senior fellow at the Center for Strategic and International Studies, a Washington think tank.

“That in itself is significant — a change from where they have been in the past 20 years, in lockstep” behind the governments of Maduro and his predecessor, Chávez, he said.

The Venezuelan defense minister, Gen. Vladimir Padrino López, appeared to offer firm backing for Maduro in a speech Thursday, charging that Guaidó was attempting a coup and pledging that the military would not support a president “imposed by shadowy interests.”

But Rocío San Miguel, a military analyst based in Caracas, said it was significant that the military waited for an entire day after Guaidó’s dramatic declaration to issue a public statement. She noted that the defense minister also emphasized that the military wanted “to avoid a confrontation between Venezuelans” and expressed appreciation for governments that were encouraging dialogue for a peaceful solution.

Such comments “suggest that there’s lots of pressure within the armed forces,” she said.

The military has a long history of political activism in Venezuela. It was the dominant political force during most of the 19th century and the first half of the 20th century. It took a back-seat role when Venezuela transitioned to democracy in 1959. But when Chávez came to power, he sought to harness the military to his socialist movement.

He increased ideological training, purged senior officers, promoted loyalists and involved soldiers in multiple aspects of his government’s projects, from distributing food to managing its oil company, PDVSA. Active-duty and retired officers filled up to one-third of cabinet portfolios, according to a paper published by several U.S. military and security experts in 2016. Maduro, who took over in 2013 when Chávez died, became even more dependent on the military’s support. Senior military officials were permitted to enrich themselves through corrupt activities, including drug trafficking, analysts said.

“That essentially tied those military leaders to the survival of the Maduro regime,” said one of the authors of the paper, Brian Fonseca, director of the Jack D. Gordon Institute for Public Policy at Florida International University. “To break with the Maduro regime means you’re vulnerable to being arrested” and possibly extradited.

The National Assembly, recognizing the military leadership’s concerns, passed a law on Jan. 15 that provides amnesty to soldiers who help push Maduro from power. Guaidó on Friday called on citizens to print out copies of the new law and give it to soldiers in their family or on the street.

Dany Bahar, a Venezuela expert at the Brookings Institution, said the opposition in the past had been critical of the military’s loyalty to the government and had not emphasized ways to lure them to its side.

“It’s the first time they are really thinking very thoroughly about the carrots” and not just sticks, he said.

The armed forces have been unusually restrained in dealing with the political crisis. They have not arrested Guaidó, who has maintained that Maduro is not the legitimate president after winning reelection in balloting in the fall that was widely denounced as fraud-ridden.

The armed forces also did not launch an all-out offensive against massive anti-government demonstrations Wednesday — although 29 people have been killed in recent days as protesters clashed with security forces using tear gas and rubber bullets in Caracas. It was not clear whether those deaths were caused by police or soldiers

One of the main sources of pressure on military leadership may be the middle and lower ranks, who have suffered like the rest of the population from hyperinflation and shortages of food and medicine. Military desertions have been soaring, and there have been small-scale signs of rebellion — such as an attack by explosives-laden drones in August that appeared to be aimed at Maduro. (He escaped unharmed.)

A professor at a military college, who spoke on the condition of anonymity to avoid reprisals, said he had observed a growing number of military personnel in the middle and lower ranks complaining to their superiors “in polite ways” about their living conditions.

But it is difficult for them to organize, he said.

“Logistically it’s hard for those who are against the government to get together without being jailed, because the institution is deeply surveilled” by intelligence services, he said.

Krygier reported from Miami.