The remarkable simple presence of Mr. López Obrador at Mr. Biden’s side underscored how awkward an already complicated relationship between the United States and Mexico has become. Mr López Obrador skipped Mr Biden’s Summit of the Americas last month after criticizing the United States for not inviting Cuba, Venezuela and Nicaragua. He has also challenged the United States over energy policies, drug enforcement and the prosecution of Julian Assange. The two leaders sought to reaffirm a partnership they both agreed was necessary to tackle global inflation amid Russia’s invasion of Ukraine, immigration and increased fentanyl trafficking. But Mr. López Obrador also appeared to indicate that there is still tension between the administrations. The Mexican president, who rarely misses an opportunity to hit out at the Biden administration, at one point mentioned how Americans living along the border were crossing into Mexico for lower-priced natural gas amid soaring inflation. “Despite our differences and also despite our grievances that are not really easy to forget with time or with good wishes,” said Mr. López Obrador, many times “we were able to get along and we were able to work together as good friends and true allies”. In a roughly 30-minute response to Mr. Biden’s brief opening remarks, Mr. López Obrador seemed at times to be giving a history lecture rather than a policy framework, citing cooperation between the two countries under President Franklin D. Roosevelt and New Deal Policies. “We had circumstances that were quite similar to our existing circumstances,” he said. “And from these policies, we should learn good lessons.” Mr. López Obrador also touched on one of Mr. Biden’s biggest political vulnerabilities: high gas prices. After telling Mr. Biden that he hoped “that Congress passes or approves” proposals to lower gas prices, Mr. Biden responded: “It’s been down for 30 days in a row.” The Mexican president also noted that Americans are crossing the border to buy natural gas, saying it is a dollar cheaper. He did not note that it costs less in Mexico because the government subsidizes domestic gas prices with money it makes from the crude oil it produces. Aides to Mr. Biden insist the relationship between the two leaders is productive. Despite not participating in Mr. Biden’s summit in June, Mexico endorsed a statement concluded during the gathering pledging to work together to expand legal pathways for foreign workers, invest in border protection, tackle networks smuggling and dealing with record high illegal immigration.

The Biden Presidency

With the midterm elections looming, here’s President Biden.

“We see Mexico as an equal partner,” Mr. Biden said Tuesday in remarks that lasted just under 10 minutes, pointing to the need to bolster the economy and approach northern migration “as a shared hemispheric challenge.” Throughout his presidency, Mr. Biden has emphasized the need to work with Mexico and Central American nations to address the root causes of immigration and stem rising illegal border crossings — a humanitarian crisis that has his White House. In recent years, the majority of migrants crossing the border have been Mexican, a shift from most of the Obama and Trump administrations when Central Americans entered the United States in record numbers. Mexico has agreed to buy up to 20,000 tons of powdered milk from the United States to help families in rural and urban communities, as well as one million tons of American fertilizer, according to a statement from the National Security Council. Mr. Biden also credited Mr. López Obrador “for speeding up” the issuance of visas for Central American immigrants to work in Mexico. Mr. Biden added that both the United States and Mexico would invest in updated infrastructure along the border. Nations are working to improve technology at port entries to better detect drugs, as well as surveillance towers and sensors to help border agents monitor illegal crossings, according to a senior administration official. While the Trump administration has invested billions of dollars to build hundreds of miles of physical border wall, Mr. Biden has campaigned on investing in technology to prevent such crossings. The White House said Tuesday that Mexico would invest $1.5 billion in infrastructure along the border, marking an unfulfilled promise by former President Donald J. Trump to make Mexico pay for the wall. The funds will be used to improve technology on the Mexican side of the border that can detect smuggling, according to a person familiar with the matter. Mr. Biden, noting the deaths of 51 migrants found trapped in an abandoned truck in San Antonio, also said the two nations needed to crack down on smugglers who encourage migrants to cross the border. The administration launched an anti-smuggling initiative with other nations that has resulted in about 3,000 arrests since April, he said. “We need every country in the region to join us,” Mr. Biden said. Mr. López Obrador cited expanding temporary work visas for Mexicans and Central Americans as one of the most effective ways to encourage legal immigration. During the summit last month, Mexico pledged to provide temporary work to at least 15,000 Guatemalans, while the United States said it would dedicate $65 million in grants to rural employers who hire farmers from Central American countries. Andrew Selee, president of the Immigration Policy Institute, a think tank in Washington, praised the effort but said implementation would likely take time. “It’s moving slowly because we need employers to want to go and hire in Central America and we need to make it easier for them to process visas,” he said. Mr. Selee said the two leaders were probably more focused on addressing the immigration and economic woes affecting both of their nations than on Mr. López Obrador’s absence from the summit. In some ways, Mr. López Obrador’s relationship with Mr. Biden is more complicated than the one he had with Mr. Trump, who threatened to impose tariffs on Mexico before eventually winning the country over as a crucial ally for his border policies. . Despite Mr López Obrador’s efforts to cast himself as an advocate for migrants, he also agreed to comply with US policies that empowered US border agents to quickly turn migrants back to Mexico. In return, Mr. Trump mostly avoided pressing him on domestic issues. Mr. Biden returned to a broader approach, one where the United States pursues national interests while emphasizing the need to fight corruption and ensure the protection of human rights. But it is equally dependent on Mexico to prevent immigration, giving Mr López Obrador significant leverage. For much of this year, the administration has continued to rely on restrictive Trump-era policies that hinge on cooperation with Mexico. The tension between the governments has existed since Mr Biden was elected, when Mr López Obrador initially refused to recognize his victory. The Mexican president has also pursued energy policies that put US investment in the sector at risk, prompting the Office of the US Trade Representative in March to express “serious concerns about the deterioration of Mexico’s energy policies.” In recent weeks, Mr López Obrador has continued to criticize the administration, criticizing the US government for bringing espionage charges against Mr Assange. The British government approved Mr Assange’s extradition to the United States last month. Mr López Obrador has vowed to “launch a campaign to tear down the Statue of Liberty” if Mr Assange is “sentenced to the maximum sentence” in the United States. “There should be no selfishness between countries, peoples who are neighbors and friends,” Mr. López Obrador said toward the end of his remarks. “President Biden,” he added, “we trust you because you respect our sovereignty.” Mr. Biden responded by noting that his counterpart had “a lot of important things to say.” “We agree with the gist of what you’re saying,” he said. “We need to work together more closely.” Natalie Kitroeff contributed reporting from Mexico City.