Joseph Y. Yun, who retired in February as the administration’s envoy to North Korea, said Mr. Trump’s tweet was a belated public recognition of “what we’ve known for a long time: The negotiations are not going well on the denuclearization front.”

“Washington must now fundamentally rethink how to approach North Korea,” he said.

Mr. Trump’s about-face was also a setback for Mr. Pompeo, who announced the appointment on Thursday of Stephen E. Biegun, a Ford Motor executive, as his special envoy. Mr. Pompeo cast the move as further evidence of the administration’s commitment to reach a deal with North Korea.

The tweets carried an echo of Mr. Trump’s handling of Mr. Pompeo’s predecessor, Rex W. Tillerson, last October. After Mr. Tillerson promoted his efforts to open a channel to North Korea, the president tweeted that he was “wasting his time trying to negotiate with Little Rocket Man.”

It was only the second time that Mr. Trump had tweeted anything other than praise for Mr. Pompeo. On Wednesday, the president tweeted that he had directed his secretary of state to scrutinize what he said was the targeting of white farmers in South Africa — a request seen by many as embracing a false narrative spread by white supremacists.

By all accounts, Mr. Pompeo has a much better relationship with Mr. Trump than Mr. Tillerson did. He has been in sync with him on the negotiating strategy with North Korea, and White House officials said that Mr. Pompeo was with the president when he sent the tweets.

Mr. Trump’s cancellation of the trip mirrored his letter to Mr. Kim in May, in which he pulled out of a planned summit meeting with him in Singapore after a series of disagreements. Mr. Kim sent an emissary to Washington to smooth things over, and the meeting was quickly reinstated.

“You can only run this play so many times,” said Evan S. Medeiros, a former senior Asia adviser to President Barack Obama. “It is much less likely to work this time. In June, Kim wanted the summit; now he can take or leave a nuclear deal.”