MEXICO CITY, Jan 26 — President Donald J. Trump’s decision to build a wall along the southern border escalated into a diplomatic standoff on Thursday, with Mexico’s president publicly canceling a scheduled meeting at the White House and Mr. Trump firing back, accusing Mexico of burdening the United States with illegal immigrants, criminals and a trade deficit.
Mr. Trump’s push to fulfill his campaign pledge and build a border wall brought to a head months of simmering tensions, culminating in a remarkable back-and-forth between the two leaders.
By afternoon, Mr. Trump’s spokesman said the president would pay for the border wall by imposing a 20 percent tax on imports to the United States, which he said would raise billions of dollars.
The sparring began Thursday morning when the president of Mexico announced on Twitter that he was canceling his meeting with Mr. Trump next week, rejecting the visit after the new American leader ordered the border wall between the two nations.
Having called for dialogue in the face of Mr. Trump’s vows to build a wall during the American presidential campaign, President Enrique Peña Nieto ultimately bowed to public pressure in Mexico to respond more forcefully to his northern neighbor.
On Wednesday, Mr. Trump signed an executive order to beef up the nation’s deportation force and start construction on a new wall along the border. Adding to the perceived insult was the timing of the order: It came on the first day of talks between top Mexican officials and their counterparts in Washington, and just days before the meeting between the two presidents.
Mr. Trump’s action was enough to prompt Mr. Peña Nieto to start discussing whether to scrap his plans to visit the White House, according to Mexican officials. In a video message delivered over Twitter on Wednesday night, Mr. Peña Nieto reiterated his commitment to protect the interests of Mexico and the Mexican people, and he chided the move in Washington to continue with the wall.
“I regret and condemn the United States’ decision to continue with the construction of a wall that, for years now, far from uniting us, divides us,” he said.
Then on Thursday morning, Mr. Trump fired back, warning that he might cancel the meeting himself if Mexico did not agree to pay for the wall.
Just before Mr. Trump fired off his Twitter post, the Mexican foreign minister and Mr. Trump’s Homeland Security secretary, John F. Kelly, were preparing to see each other for a scheduled 11:30 a.m. meeting.
According to a senior American official, the secretary had been briefed. The appropriate flags had been arranged by the protocol staff at the Department of Homeland Security. Then, just as American officials greeted the minister outside the department’s headquarters in Northwest Washington, the minister received word from Mexico that he was being pulled back, the official said. The meeting never happened.
By early afternoon, Mr. Trump said it was the United States that was being treated unfairly.
“We have agreed to cancel our planned meeting,” Mr. Trump said in a new conference Thursday afternoon. “Unless Mexico is going to treat the U.S. fairly, with respect, such a meeting would be fruitless, and I want to go a different route. We have no choice.”
In Mexico, Mr. Peña Nieto had little political room to maneuver. With Mr. Trump’s order to build the wall, the perceived insults Mexico had endured during the campaign had finally turned into action. Decades of friendly relations between the nations — on matters involving trade, security and migration — seemed to be unraveling.
Calls began to come in from across the political spectrum for Mr. Peña Nieto to cancel his visit, and to respond with greater fortitude to the perceived menace from President Trump. On Twitter, Mr. Trump’s action was referred to by politicians and historians as a “an offense to Mexico,” a “slap in the face” and a “monument to lies.”
Historians said that not since President Calvin Coolidge threatened to invade a “Soviet Mexico” had the United States so deeply antagonized the Mexican populace.
“It is an unprecedented moment for the bilateral relationship,” said Genaro Lozano, a professor at the Iberoamerican University in Mexico City. “In the 19th century, we fought a war with the U.S.; now we find ourselves in a low-intensity war, a commercial one over Nafta and an immigration war due to the measures he just announced.”