MEXICO CITY — During the later years of Bolivian President Evo Morales’s tenure in office, when he raised concerns by challenging term limits and jailing opposition leaders, he kept at least one strong ally in Mexico: Andrés Manuel López Obrador.

López Obrador was a fixture of Mexico’s left, a former activist who came of age politically working on indigenous rights, a cause that connected him with Bolivia’s first indigenous president, along with their shared public distaste for neoliberalism.

When López Obrador was elected president of Mexico last year, he invited Morales to his inauguration. Morales anointed his friend “the shining hope for the people of Mexico.” López Obrador had written to Morales in 2010 to convey his “deep respect for the way in which you have been able to represent the noble, conscious and progressive people of Bolivia.”

Until this week, that allegiance seemed of little geopolitical relevance, more a rhetorical connection between the vanguards of Latin American populism, a dwindling group of leaders in the age of Brazil’s Jair Bolsonaro, Colombia’s Iván Duque and Chile’s Sebastián Piñera.

Then, Morales was forced from power Sunday amid a damning election audit by the Organization of American States and rising opposition protests. Mexico immediately offered him political asylum; Foreign Minister Marcelo Ebrard said his life was at risk.

Morales’s escape to Mexico allows López Obrador to reaffirm his leftist bona fides, after a year in which he implemented a series of harsh anti-migration policies at the goading of the Trump administration and pushed for the passage of a new North American free trade deal.

In those actions, many here saw López Obrador drifting away from his leftist roots and toward a kind of centrism, particularly in his foreign policy. But in welcoming Morales, he is taking a side in one of the region’s most volatile political conflicts, with the potential for negative consequences.

On leaving Bolivia, Morales tweeted that he would return soon “with more strength and energy.” As he landed Tuesday in Mexico, it was unclear how long he would stay or what he planned to do.

“The whole world knows that I will not change ideologically because of this coup,” he told reporters at Mexico City International Airport. “They know well we have reduced extreme poverty. It is one more lesson to learn, one more lesson to strengthen the struggle of the people in Bolivia and the world.”

Violent protests continued in Bolivia, which has been without a leader since the resignations Sunday of Morales, his vice president and the heads of the senate and chamber of deputies. Soldiers took to the streets of La Paz and El Alto at the request of police who said they came under attack.

At least five people have died since the unrest began last month. Col. Heybert Antelo, a police commander in La Paz, succumbed Tuesday to injuries from a car crash Sunday.

Former president Carlos Mesa, who finished second to Morales in last month’s disputed election, condemned the violence. He expressed “solidarity” for the “hundreds of Bolivians who were victims of MAS violent groups that have sowed violence and terror and have destroyed a big part of Bolivia.”

MAS, the Movement for Socialism, is Morales’s party. Opposition protesters are also accused of violence.

Jeanine Añez, second vice president of the senate, assumed the interim presidency of the country after lawmakers met Tuesday afternoon to accept resignations. She was named new head of senate, and because she was in the constitutional line of succession, she said she would “immediately” start serving as the interim president. The session started more than an hour late because of a lack of quorum. Morales deputies, who represent a majority in congress, had been debating whether to attend, and according to local media, the decision ended up being made without their presence. Morales supporters filled the streets of La Paz and clashes continued.

In Mexico, the division over Morales was immediately apparent. In Mexico City, the two top trending topics on Twitter were, in Spanish: #EvoWelcomeToMexico and #EvoYou’reNotWelcomeInMexico.

“I am sure giving Morales asylum is the good thing to do,” said Carlos Bravo Regidor, a Mexican political analyst. “But is it right for Mexican foreign policy interests? I don’t know.

“Where does this leave Mexico? Are we now part of the Bolivarian axis?”

Some analysts said they approved of the offer of asylum, as long as it didn’t come with an ideological message. Mexico’s constitution doesn’t allow for a president to be reelected, making Morales’s attempt to remain in power in Bolivia concerning to many.

“I hope that, with this, the Mexican government is not sending the message that there is ideological support for remaining in power beyond term limits,” said Emilio Alvarez Icaza, an independent senator and former human rights activist.

“If this is only a humanitarian response, if it remains only in that, I support it,” he said. “But if the Mexican government wants to build from here in an effort to legitimize extending the mandate of López Obrador, I would raise my voice.”

Krygier reported from Miami.