KABUL, Afghanistan — In a bid to regain control of a peace process with the Taliban that had suddenly spun out of control, President Hamid Karzai on Wednesday slammed the brakes on two strategic lines of American negotiation, again exercising his power in a strained alliance and getting results.

Mr. Karzai reacted in fury after an apparent diplomatic breakthrough on Tuesday — the opening of a Taliban peace office in Qatar — instead became a publicity coup for the Taliban. In televised images that horrified many Afghans, the Taliban introduced what appeared to be an embassy, raising their flag, speaking in front of a sign declaring the “Islamic Emirate of Afghanistan,” the name of their former government and seeking international exposure.

First, Mr. Karzai broke off long-term security talks with the United States, accusing the Americans of failing to deliver on promises to keep the Taliban from grandstanding. Soon after, his office announced that the government delegation would stay away from the talks until the insurgents removed their symbolic displays of being an alternative government.

The president’s gambit appeared to work: In a turbulent 24 hours of nonstop diplomatic moves, Secretary of State John Kerry called Mr. Karzai three times and successfully pushed the Qatari government to get the Taliban to take down the sign and flag, American and Afghan officials said.