Defense Secretary Jim Mattis said Tuesday that it is in the United States' national security interest to remain in the Iran nuclear deal despite President Trump's criticism that the agreement is an "embarrassment."

Mattis, who was testifying before the Senate, said he supports what he called a "rigorous review" by Trump, but that he would advise keeping the Joint Comprehensive Plan of Action, which was signed by the Obama administration to keep Tehran from developing nuclear weapons.

Under the Iran Nuclear Agreement Review Act, the deal must be re-certified by the Trump administration by Oct. 15. Not certifying the deal doesn't mean the U.S. is walking away from it, but it does open the possibility that Congress could reimpose sanctions that were lifted as part of the deal.

"If we can confirm that Iran is living by the agreement, if we can determine that this is in our best interest, then clearly we should stay with it," he told the Senate Armed Services Committee. "I believe at this point in time, absent indications to the contrary, it is something the president should consider staying with."

Trump has long criticized the Joint Comprehensive Plan of Action as a terrible deal, and after more searing criticism before the U.N. General Assembly last month, told reporters he had decided on whether he would certify to Congress that it's in America's national security interest to stay with the agreement.

Iran had threatened to destabilize the Middle East with its pursuit of nuclear weapons and the U.S. brokered a deal with a number of developed countries to head off that effort. But the deal has been roundly criticized by Republicans for giving concessions to Tehran as it supports terrorism and works against U.S. interests in the region.

Asked by Sen. Angus King, I-Maine, whether it's in the country's national security interest to remain in the deal, Mattis paused for several seconds before saying "yes." He also told senators that Trump may be looking at a broader definition of security.

"The president has to consider more broadly things that rightly fall under his portfolio of looking out for the American people in areas that go beyond the specific letters of the JCPOA," Mattis said. "In that regard, I support the rigorous review that he has got going on right now."