Defense Secretary Jim Mattis testified Tuesday that the United States should remain in the Iran nuclear deal, as President Trump weighs whether to renew the controversial agreement ahead of an Oct. 15 deadline.

The president has been highly critical of the Obama-era pact, as recently as last month calling it one of the "worst deals" he's ever seen.

But Mattis and Chairman of the Joint Chiefs of Staff Gen. Joseph Dunford both indicated support for the agreement during a hearing Tuesday before the Senate Armed Services Committee.

Mattis was pressed by Sen. Angus King, I-Maine, on whether he thought there was a “national security interest” to remain in the Iran deal.

“Yes, sir. I do,” Mattis said.

Late last month, Secretary of State Rex Tillerson suggested that the president had made his decision on whether to withdraw from the agreement but had not shared that decision “externally.”

The president, who has twice re-certified the deal since taking office, has repeatedly slammed the arrangement. He told reporters last month that it's not "fair" and should never have been made.

But Trump has not said whether he plans to re-certify Iran's compliance by the Oct. 15 deadline. Denying certification could lead the U.S. to reintroduce sanctions, which could lead Iran to walk away from the deal or even restart some nuclear activities it had engaged in prior to the 2015 agreement.

Dunford testified Tuesday that Iran, however, is following the requirements of the deal.

“The agreement right now, what I testified to last week, Iran is not in material breach of the agreement,” Dunford told lawmakers on the panel. “And I do believe the agreement, to date, has delayed the development of nuclear capability by Iran.”

Mattis noted that while he believes it is in the best interest of the U.S. to abide by the nuclear deal, the administration is “very alert” to any “cheating” by the Iranians.

“The amount of misconduct, I would call it, internationally, whether it be with ballistic missiles, rhetoric, support to terrorists, threats to our friends, Arab and Israel in the region by Iran, are areas that they are open to a great deal, I think, of censure by the international community,” Mattis said. “We are not naive about their agreement on the nuclear issue, and we are being very alert to any cheating on that right now.”

Congress requires the president to certify the Iran deal every 90 days under law.

“They are two different pieces,” Mattis said, referring to the Iran Nuclear Agreement Review Act and the international agreement. “I’ve been dealing with the president and the secretary of state and it is being considered in terms of security for the U.S.—the law plus the agreement.”

Fox News' Lucas Tomlinson and the Associated Press contributed to this report.