After years of close ties with Donald Trump, Mexico must now reshape its complex relations with the United States under Joe Biden, including on the key issues of trade and immigration.
The country's awkward position was underscored by President Andres Manuel Lopez Obrador's reluctance on Saturday to congratulate Biden while Trump is still mounting a slew of legal challenges.
The left-wing populist said he would wait for "all legal issues" in the US presidential election to be resolved.
"We don't want to be imprudent. We don't want to act lightly," Lopez Obrador told a news conference.
"We have a very good relationship with the two candidates," he added, as messages of congratulations for Biden and Vice President-elect Kamala Harris poured in from other world leaders.
Trump sparked anger during his 2016 election campaign when he branded Mexican migrants "rapists" and drug dealers, and vowed to build a wall across the southern US border.
Even so, Lopez Obrador maintained cordial relations with Trump, and experts say that a Biden presidency will bring a different set of challenges for Mexico.
"Trump's anti-Mexican rhetoric is very unpleasant, but in fact there were important agreements," said Miguel Angel Jimenez, analyst at the Mexican Council on Foreign Relations, told AFP.
"The relationship with the Democrats has always been cold and Biden could keep more distance."
- 'Unpleasant situation' -
Mexico has previously gained more from Republican administrations, such as the immigration amnesty granted by Ronald Reagan and the NAFTA free trade agreement negotiated under George H.W. Bush, Jimenez said.
Lopez Obrador's cautious reaction to Biden's win reflects his close relationship with Trump and the fact that the Republican still has weeks left in office, he said.
"It's an unpleasant situation for the Mexican government," Jimenez added.
The Mexican leader chose to visit Trump in the United States in July on his first foreign trip since taking office.
Lopez Obrador's close ties with Trump mean his defeat "could be a political setback," said Gabriela Siller, an analyst at Banco Base.
"Biden already omitted Mexico when congratulating Latin American countries celebrating their independence" anniversaries in September, she noted.
While Biden is unlikely to make any radical policy announcements concerning Mexico, his victory could still have repercussions, particularly in trade, analysts said.
The renegotiation of the trade agreement between the United States, Canada and Mexico was the climax of a complicated relationship with Trump.
- 'Obstacles in path' -
The future of the US-Mexico-Canada Agreement (USMCA), which entered into force in July, replacing NAFTA, is a major concern for Mexican authorities as Biden prepares to move into the White House.
"Trump already did what he wanted with Mexico, the risk with him would be less," said Siller.
Harris "was an opponent of USMCA and they could put obstacles in its path," she added.
The Democrats are expected to demand punctual compliance with labor reform that they requested in return for approving the agreement with the key trading partner, Jimenez said.
In 2019, Trump threatened to slap tariffs on imports from Mexico if it did not stop a wave of Central American migrants heading overland to the United States.
Even if Biden cancels Trump's planned construction of a border wall, strict restrictions against undocumented migration will continue, said Maria Dolores Paris Pombo, an expert at the Colegio de la Frontera Norte in Tijuana in northwest Mexico.
He may revive a program put in place by then-president Barack Obama in 2012 to regularize the immigration status of hundreds of thousands of young people, known as "Dreamers," who had arrived illegally as children.
Biden has fiercely criticized Trump's efforts to shut down the Deferred Action for Childhood Arrivals (DACA).
But previous Democratic administrations have also applied laws passed in the late 1990s criminalizing undocumented immigration, Paris Pombo noted.
"Barack Obama's administration was tougher in terms of the number of deportations, but without the media impact or levels of Trump's cruelty," she said.