WASHINGTON — President Trump agreed on Monday to certify again that Iran is complying with an international nuclear agreement that he has strongly criticized, but only after hours of arguing with his top national security advisers, briefly upending a planned announcement as a legal deadline loomed.

Mr. Trump has repeatedly condemned the deal brokered by President Barack Obama as a dangerous capitulation to Iran, but six months into his presidency he has not abandoned it. The decision on Monday was the second time his administration certified Iran’s compliance, and aides said a frustrated Mr. Trump had told his security team that he would not keep doing so indefinitely.

Administration officials announced the certification on Monday evening while emphasizing that they intended to toughen enforcement of the deal, apply new sanctions on Iran for its support of terrorism and other destabilizing activities, and negotiate with European partners to craft a broader strategy to increase pressure on Tehran. Aides said Mr. Trump had insisted on such actions before agreeing to the consensus recommendation of his national security team.

“The president has made very clear that he thought this was a bad deal — a bad deal for the United States,” Sean Spicer, the White House press secretary, told reporters at a briefing on Monday before the decision was made.

By law, the administration is required to notify Congress every 90 days whether Iran is living up to the deal, which limited its nuclear program in exchange for the lifting of many international sanctions. With the latest deadline approaching on Monday, the issue set off a sharp debate between the president and his own team, starting last week, aides said.

At an hourlong meeting last Wednesday, all of the president’s major security advisers recommended he preserve the Iran deal for now. Among those who spoke out were Secretary of State Rex W. Tillerson; Defense Secretary Jim Mattis; Lt. Gen. H. R. McMaster, the national security adviser; and Gen. Joseph F. Dunford Jr., the chairman of the Joint Chiefs of Staff, according to an official who described internal discussions on the condition of anonymity. The official said Mr. Trump had spent 55 minutes of the meeting telling them he did not want to.

Mr. Trump did not want to certify Iran’s compliance the first time around either, but was talked into it on the condition that his team come back with a new strategy to confront Tehran, the official said. Last week, advisers told the president they needed more time to work with allies and Congress. Mr. Trump responded that before he would go along, they had to meet certain conditions, said the official, who would not outline what the conditions were.

While Mr. Trump headed to Paris and then spent the weekend in New Jersey, his team developed a strategy that it hoped would satisfy him and planned to notify Congress and make the case publicly on Monday. But even as allies were quietly being informed, Mr. Trump balked when he heard the plan at his morning security briefing, the official said. The argument continued during a separate meeting with Mr. Tillerson as Mr. Trump pressed for more action, the official said. Continue reading.