WASHINGTON — Secretary of State Mike Pompeo on Friday excoriated John Kerry, who was the top American diplomat in the final years of the Obama administration, for meeting with Iranian officials in what he described as “unseemly and unprecedented” discussions.

“Actively undermining U.S. policy as a former secretary of state is literally unheard-of,” Mr. Pompeo said in a brief appearance at the State Department’s press briefing room.

His remarks came amid a Twitter spat between Mr. Kerry and President Trump over the American withdrawal this year from the Iran nuclear deal that the Obama administration had brokered.

While promoting his new book, a memoir of his career, Mr. Kerry said this week that he had met with Foreign Minister Mohammad Javad Zarif of Iran “three or four times” since leaving office. He said the discussions included the nuclear deal that Mr. Trump jettisoned in May, and defended the talks on Wednesday by saying that it was not uncommon for former secretaries of state to continue meeting with world leaders long after leaving government service.