WASHINGTON — For much of Wednesday, the Trump administration played hardball, spreading word that it was considering the shocking step of withdrawing from the North American Free Trade Agreement.

Advisers to President Trump said he wanted to announce an executive order beginning the process of withdrawing from the deal at a Saturday evening rally marking his 100th day in office. The rally is being held in Harrisburg, Pa. — in the heart of a region where many people regard Nafta as a dirty word.

But by the end of the night, the White House was in full retreat after the news caused panic in Washington, Ottawa and Mexico City. The president of Mexico and the prime minister of Canada both called Mr. Trump to warn against such a precipitous step. Mr. Trump said Thursday morning that he had been persuaded by their calls to focus on reworking the trade agreement.

“I decided rather than terminating Nafta, which would be a pretty big, you know, shock to the system, we will renegotiate,” Mr. Trump told reporters at the White House. He added that he was still ready to pull the United States out of the deal if he could not rework it to his satisfaction.