MEXICO CITY — Mexican officials said Thursday they would file a formal complaint against Bolivia in the International Court of Justice in The Hague over the harassment of their diplomats in the South American country.

Mexico says that Bolivian security forces have encircled the Mexican embassy in La Paz, flown drones overhead and harassed the Mexican ambassador.

The Mexican embassy has given refuge to nine former officials from the administration of President Evo Morales, the socialist stalwart who resigned and fled the country in November amid allegations of election fraud.

Leftist Mexican President Andrés Manuel López Obrador granted Morales asylum in Mexico, inflaming tensions with Bolivia’s conservative interim government. Morales has since moved on to Argentina.

Mexico’s decision to give refuge to former Bolivian officials including Juan Ramón Quintana, Morales’s chief of staff, deepened the rift. Mexican officials say the Bolivians could be in danger if they leave the embassy. The Bolivian government of interim president Jeanine Áñez has issued arrest warrants against five of the nine.

“We are following our historical tradition of protecting persecuted politicians,” said Roberto Velasco, a spokesman for Mexico’s foreign ministry.

The Bolivian foreign ministry says Mexico is obstructing Bolivia’s internal affairs. In a statement, the ministry criticized Mexico for refusing to hand over the former officials “for committing common crimes.”

Bolivian officials deny violating Mexico’s diplomatic immunity. They say the security presence around the Mexican embassy and ambassador’s residence is there for protection.

Bolivian foreign minister Karen Longaric told reporters Thursday that the Mexican government, through its ambassador in La Paz, asked for reinforced security on Nov. 19 and 29. The ambassador, Longaric said, expressed concern about protests against the former officials inside the embassy.

Mexican officials disputed Longaric’s account. They have distributed photos of Bolivian officials deployed around the embassy and the ambassador’s residence.

“The Bolivian authorities are very confused: Stopping a diplomatic car with the ambassador on board, setting up a military camp on the hill or filming those who come and go from the residence is not protection, it is harassment,” Efraín Guadarrama, a senior Mexican foreign ministry official, wrote in a tweet.

While the dispute focuses on Mexico’s unwillingness to hand over the former Bolivian officials, it threatens to expand into a larger clash between the two countries. Morales and López Obrador have had a strong relationship, presenting themselves as fixtures of the Latin American left.

Bolivia’s election tribunal declared Morales the winner of the country’s presidential election in October. But after the Organization of American States reported that it had found “clear manipulation” of the vote, opponents began burning the homes of lawmakers from Morales’ Movement for Socialism party, and Morales resigned after nearly 14 years in office.

Áñez, a second vice president in the Bolivian senate, declared herself the country’s interim president and was recognized by the United States and other countries. Her administration is now charged with setting a date for a new election.

Morales’s supporters have described the sequence of events as a “coup.”

Longaric told the Mexican news site La Silla Rota Wednesday that López Obrador has¨the objective of destabilizing the current government and favoring Evo Morales in his pretensions to manipulate the next general elections.”

Morales has said he will not run for president in the coming election, but he will serve as campaign manager for his party.

Bolivian analyst Gonzalo Mendieta described the row as predictable.

“It’s not a new discovery that the relations between the Mexican government and the current Bolivian one were tense since the first moments after Morales’s resignation and López Obrador’s initial reaction,” he said.

But he said it was unlikely Bolivia would attempt to enter the Mexican embassy.

“No one with sane judgment can imagine an intervention,” he said. “I understand those inside feel pressure and want more security, but there’s no way Bolivia ignores the diplomatic conventions.”