MEXICO CITY — In the 19 months since he took office, President Andrés Manuel López Obrador hasn’t left the country once. This week, he’s traveling to Washington, to greet the world leader who has perhaps been the most demeaning to Mexico.

In the midst of a pandemic. And a U.S. election campaign.

The visit Wednesday has puzzled and angered politicians in both countries. Thirteen Democrats of the 38-member Congressional Hispanic Caucus called on President Trump to postpone the meeting, calling it “a blatant attempt to politicize the important U.S.-Mexico relationship” and a ploy to shift attention from the coronavirus pandemic.

Mexicans, too, worry that the leaders’ first face-to-face meeting will imply López Obrador’s support for Trump’s reelection bid. If Trump loses to candidate Joe Biden, and Democrats take control of both houses of Congress, former foreign minister Bernardo Sepúlveda warned, “the bilateral relationship will be full of difficulties, and Mexico will be the main loser.”

The ostensible purpose of the trip is to celebrate the start of the updated United States-Mexico-Canada trade deal, which the two presidents have described as among their signature accomplishments. In a statement, Trump said he looked forward to continuing “our important dialogue on trade, health, and other issues central to our regional prosperity and security.”

It’s expected to be a largely symbolic visit. But it underscores how the two populists from opposite ends of the political spectrum have forged a surprisingly warm relationship. López Obrador, a longtime standard-bearer of Mexico’s left, has adopted a sort of tropical realpolitik with his country’s largest trading partner, acquiescing to Trump’s demands to limit migration.

“Trump had to be accommodated,” said Federico Estévez, a political scientist at the Instituto Tecnológico Autónomo de México, for Mexico to achieve its main goal: Preserving the free-trade treaty. “We’re not Canada,” he said. “We couldn’t afford not to go this route.”

Early in López Obrador’s presidency, it looked as if he would clash with Trump on immigration. López Obrador had long described migration as a human right and championed Mexican workers in the United States.

But a year ago, when the Trump administration threatened to slap tariffs on Mexican exports if the country didn’t curb the number of asylum seekers crossing the country, López Obrador deployed the new National Guard and detained tens of thousands of Central Americans. He also accepted the Trump administration’s Migrant Protection Protocols, under which asylum seekers are returned to Mexico while they wait, often for months in shelters or makeshift camps, for their U.S. hearings.

Those policies helped produce a dramatic decline in migration, and Trump has since praised López Obrador, who is widely known by his initials, AMLO.

“Under AMLO, Mexico has turned into a virtual wall for the United States,” said Maureen Meyer, director for Mexico and migrant rights at the Washington Office on Latin America. “AMLO’s priority was to maintain the relationship with the U.S., and he was willing to accept those costs in Mexico.”

Now, though, the number of Mexicans apprehended at the border is increasing — and could rise further if the U.S. economy recovers while Mexico’s continues to sputter.

The International Monetary Fund expects Mexico’s GDP to plunge by 10.5 percent this year — one of the worst contractions in Latin America. Analysts say López Obrador’s visit to Washington reflects his belief that the trade deal is crucial to “reactivating the economy.”

But there’s little reason, they say, to believe the trade agreement will create significantly more jobs than existed under the North American Free Trade Agreement, its predecessor.

“The deal offers investors certainty, but 95 percent of it is basically the same as NAFTA,” said Valeria Moy, an economist and professor at the Instituto Tecnológico Autónomo de México.

And economists say the trade deal is unlikely to drive much new foreign investment, given uncertainty created by the López Obrador administration. He has canceled a new Mexico City airport project and a U.S. firm’s $1.4 billion brewery in Mexicali on allegations of corruption, and backpedaled on reforms to open the energy sector to more private investment.

The Washington trip carries potential peril as well as benefits for López Obrador.

Trump was an outspoken critic of Mexico during his first campaign and early days in office. He slammed NAFTA as “the worst trade deal in history” and accused the country of sending drugs and criminals to the United States.

During the 2016 campaign, then-President Enrique Peña Nieto received Trump at Los Pinos, the Mexican White House. Within hours, the Republican candidate enraged his hosts by declaring he would build a “great wall” on the border — and make Mexico pay for it. Peña Nieto was excoriated for having hosted Trump.

Trump remains deeply unpopular in Mexico. But López Obrador appears to have paid little price for accommodating him. The Mexican leader said Monday that Trump had changed his tune toward the country.

“Our adversaries say, ‘How can I go if he’s offended Mexicans?’ ” López Obrador said. “I want to tell the people that, since we have been in government, there has been a relationship of respect, not only toward the government, but above all, toward the Mexican people.”

Mexican officials say Trump has provided more than 400 ventilators during the pandemic and assisted the country in negotiations with OPEC on cuts in oil production. The Washington visit could allow López Obrador to emphasize a successful trade negotiation at a time when he’s been widely accused of mishandling the pandemic. More than 30,000 Mexicans have died of covid-19, the world’s fifth-highest toll.

Canadian Prime Minister Justin Trudeau, who was also invited to the meeting in Washington, has declined to attend. López Obrador tweeted Monday that Trudeau would visit Mexico “as soon as possible.”

In keeping with his image of austerity, López Obrador plans to fly on a commercial jet to Washington. His schedule includes visits to the Lincoln Memorial and a statue of the 19th-century president and political reformer Benito Juárez near the Kennedy Center. He’s also scheduled to dine with business executives, according to Mexican news reports.

López Obrador said he would be tested for covid-19 before he left Mexico and repeat the exercise in Washington if asked. Officials said last week that López Obrador had never been tested.

He has no plans to meet with migrant groups or with Biden or other Democrats. If Biden wins, said Luis Rubio, president of the Mexican Council of International Affairs, Mexican officials “believe they can talk their way out of a problem with the Democrats.”

Biden has been more supportive of migrant rights and international agreements than Trump. Nonetheless, Democrats are annoyed by a visit that could be used to boost Trump’s standing as his campaign struggles. If Trump is defeated this November, Rubio said, “it will be a very costly visit.”