Under threats from President Trump that included steep tariffs, President Gustavo Petro of Colombia has relented and will allow U.S. military planes to fly deportees into the country, after turning two transports back in response to what he called inhumane treatment.

The two leaders had engaged in a war of words on Sunday after Colombia’s move to block Mr. Trump’s use of military aircraft in deporting thousands of unauthorized immigrants.

But on Sunday night, the White House released a statement in which it said that because Mr. Petro had agreed to all of its terms, the tariffs and sanctions Mr. Trump had threatened would be “held in reserve.” Other penalties, such as visa sanctions, will remain in effect until the first planeload of deportees has arrived in Colombia, the statement said.

“Today’s events make clear to the world that America is respected again,” it added.

Colombia’s foreign ministry released a statement soon afterward that said “we have overcome the impasse with the United States government.” It said the government would accept all deportation flights and “guarantee dignified conditions” for those Colombians on board.

Mr. Petro began the day by announcing that he had turned back U.S. military planes carrying deported immigrants. This set off a furious back and forth with Mr. Trump, who in turn announced a barrage of tariffs and sanctions targeting the country, which has long been a top U.S. ally in Latin America.

Mr. Trump said on social media that the United States would immediately impose a 25 percent tariff on all Colombian imports and would raise them to 50 percent after a week. The Trump administration would also “fully impose” banking and financial sanctions on Colombia, apply a travel ban on Colombian government officials and their associates, and revoke their visas, the president said.

Mr. Petro hit back on social media. In one post, he announced retaliatory tariffs of 25 percent on U.S. imports to Colombia; in another, longer post, he said those tariffs would hit 50 percent.

Directly addressing Mr. Trump, Mr. Petro also questioned whether the American president was trying to topple him.

“You don’t like our freedom, fine,” Mr. Petro said. “I do not shake hands with white enslavers.”

The clash reflected how Mr. Trump was ready to make an example out of Colombia as countries around the world grapple with how to prepare for the mass deportations of unauthorized immigrants that he has promised.

“This looks like a pretty bold and daring escalation on both sides,” said Will Freeman, a fellow for Latin America studies at the Council on Foreign Relations, citing Colombia’s economic reliance on the United States, which is still the South American country’s largest trading partner even as China has been making inroads.

“But equally, for Trump to threaten Colombia this way is pretty bold itself,” Mr. Freeman added. “That’s because Colombia remains historically the longest standing, the deepest, strategic ally in the region.”

Mr. Trump signed an executive order last week authorizing the U.S. military to assist in securing the border, and the Department of Defense said it would use military aircraft to deport people held in U.S. custody along the southern border.

Mr. Petro said Sunday in a series of posts that Colombia would not accept military deportation flights from the United States until the Trump administration provided a process to treat Colombian migrants with “dignity and respect.”

“I cannot make migrants stay in a country that does not want them,” Mr. Petro wrote, “but if that country sends them back, it should be with dignity and respect for them and for our country.”

He said he was still open to receiving deportees on nonmilitary flights.

Secretary of State Marco Rubio said in a statement, “Colombian President Petro had authorized flights and provided all needed authorizations and then canceled his authorization when the planes were in the air.”

Mr. Petro’s office said the presidential plane would be made available to transport the migrants who had been scheduled to arrive on the military planes. Representatives for Colombia’s Foreign Ministry did not immediately respond to requests for comment.

The immediate snag with the deportation flights appeared to be that U.S. military planes were transporting the undocumented migrants, a U.S. military official said on Sunday.

The two U.S. aircraft that were denied the ability to land in Colombia were Air Force C-17 transport planes. One turned around and returned to San Diego; the other flew back to Texas.

Mr. Petro’s remarks came in response to a post about the treatment of Brazilian deportees. Brazil’s foreign ministry complained of “degrading treatment” of its citizens after 88 migrants arrived in the country handcuffed on Friday and some complained of mistreatment after not being given water or allowed to use the bathroom during the flight.

Since taking office last Monday, Mr. Trump has issued a series of executive orders and made other moves aimed at laying the groundwork to deport an enormous number of migrants.

In his missive on social media, Mr. Trump called Mr. Petro, a former left-wing guerrilla, a “socialist” — a term that Mr. Petro has no problem in using to describe himself — and contended that Mr. Petro was “very unpopular.” Mr. Petro’s approval ratings stand at around 34 percent, as he has been weighed down by corruption scandals and a resurgence in fighting among armed groups.

To justify his measures targeting Colombia, Mr. Trump also claimed that the military deportation flights refused landing by Mr. Petro included a “large number of Illegal Criminals” and that the United States was seeking the “return of the Criminals they forced into the United States.”

The U.S. tariffs that Mr. Trump had threatened would deal a significant blow to Colombia’s economy. The United States is Colombia’s largest trading partner, with top Colombian exports to the American market including crude oil, coffee and cut flowers.

Trade between the two countries totaled $53.5 billion in 2022, with the United States having a trade surplus of $3.9 billion that year. Colombia is the largest South American market for U.S. agricultural products, absorbing imports of American pork, dairy products, alcoholic beverages, and dog and cat food.

Mr. Petro also cast attention on Americans living in Colombia, saying that more than 15,000 Americans were living in the country without authorization, and calling on them to “regularize” their immigration status.

Colombia is not among the countries with the largest unauthorized immigrant populations in the United States, trailing far behind Mexico, El Salvador, India, Guatemala and Honduras. In 2022, Mexicans remained the most common nationality among unauthorized immigrants in the United States, with about 4 million, while Colombia had about 190,000, according to the most recent data available from the Pew Research Center.

Colombia has traditionally been a close U.S. ally, though differences have recently emerged regarding counternarcotics policies. While Mr. Petro has criticized the United States more than past presidents, he continued to collaborate with the United States and regularly accepted deportation flights, said Sergio Guzmán, a Colombian political analyst.

This is what “makes this new approach so surprising,” Mr. Guzmán said earlier on Sunday.

Mr. Petro, who took office in 2022, is Colombia’s first leftist president and a longtime leader in Colombian politics known for his combative stances, particularly when it comes to defending human rights.

A former rebel who later demobilized and became a senator, his critics say he sometimes acts rashly and refuses to listen to advisers.

He has long been critical of the outsize power the United States holds in the world, particularly of the economic imbalance between the U.S. and other nations.

The Trump administration is sending the military planes in addition to the usual flights operated by ICE, meaning that they do not replace the typical flights that land several times a week in countries throughout the region, and which Mr. Petro referred to in his online posts on Sunday as “civilian” planes.

The new planes sent by the military can only depart from the United States if the receiving nation has approved them.

It is unclear which countries may have agreed to receive military planes carrying deportees.

Early on Friday, Guatemala received two U.S. Air Force jets carrying around 160 deportees in total, making it one of the first countries to publicly receive such flights.

Officials in Mexico, the source of the largest number of unauthorized immigrants in the United States, have said that they remained open to receiving deported citizens. Routine deportations have taken place to Mexican cities along the U.S. border in recent days.

Still, Mexican authorities have not disclosed whether they plan to accept military flights or whether they will receive deported migrants from other countries, as Mexico has sometimes done in the past.

On Friday, NBC reported that Mexico had refused to authorize a military plane carrying deportees from the U.S., an account that could not be independently confirmed.

Honduras, which like Colombia has pushed back against the Trump administration’s plans for mass deportations, has said that it has not yet explicitly been asked by U.S. officials, but that it is open to receiving military flights.

Eric Schmitt contributed reporting from Washington, Jack Nicas from Rio de Janeiro, Julie Turkewitz from Bogotá, and Jody García from Guatemala City, Guatemala.