US Defense Secretary Jim Mattis at a press conference with Indian Defense Minister Nirmala Sitharaman in New Delhi, September 26, 2017. Associated Press/Manish Swarup

Defense Secretary Jim Mattis on Tuesday broke with the position President Donald Trump has taken against the 2015 Iran nuclear deal during testimony before the Senate Armed Services Committee.

Asked by Independent Maine Sen. Angus King whether the deal, officially called the Joint Comprehensive Plan of Action, was beneficial to the US, Mattis answered affirmatively.

"Do you believe it's in our national security interests at the present time to remain in the JCPOA?" King asked, adding after a brief pause, "That's a yes-or-no question."

Mattis himself paused several seconds before answering, "Yes, senator, I do."

The defense secretary later elaborated, saying he supported a "rigorous review."

"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," Mattis said. "I believe at this point in time, absent indications to the contrary, it is something the president should consider staying with."

Trump's hostility toward the deal — signed in 2015 by Iran, the US, Russia, France, Germany, China, and the UK — is longstanding. During his presidential campaign, Trump tarred the agreement as a "bad deal" for the US and vowed to rip it up upon taking office.

Trump has twice recertified the deal since taking office, as he is required to do every 90 days to keep Congress from reimposing sanctions. But his administration has agreed to other sanctions on Tehran, and Trump's rhetoric has signaled he's getting closer to scrapping the deal outright.

He decision to recertify the deal a second time in mid-July only came "after hours of arguing with his top national security advisers, briefly upending a planned announcement as a legal deadline loomed," according to The New York Times.

In August, The Guardian reported that the Trump White House was pushing intelligence analysts to provide justification for declaring Iran in violation of the tenants of the deal. That pressure reportedly reminded some of the analysts involved of the run-up to the invasion of Iraq in 2003.

"They told me there was a sense of revulsion. There was a sense of déjà vu," said Ned Price, a former CIA analyst who served as special adviser to Obama. "There was a sense of, 'We've seen this movie before.'"

Then-US Secretary of State John Kerry with Iranian Foreign Minister Javad Zarif, right, at the Austria Center in Vienna, July 14, 2015. Thomson Reuters

During Trump's address at the UN in late September, he again targeted Tehran, saying the country was a "rogue nation" and calling the nuclear deal "an embarrassment."

"It is time for the entire world to join us in demanding that Iran’s government end its pursuit of death and destruction," Trump said.

Trump is also out of step with nuclear inspectors, who have found no evidence Iran has violated the deal.

His stance also differs from that of other signatories, four of whom signed a statement that said, "Unilateral US action that jeopardized the JCPOA would be a grave mistake" and would harm US and European interests. Israeli officials, including a former national security adviser, have also called on Washington to preserve the deal.

Some in the White House, Pentagon, and State Department are reportedly preparing from Trump not to recertify the deal by the October 15 deadline. Should he send it back to Congress, Republicans could kill it with a simple majority vote. But there's no guarantee the GOP would get that, as some members have expressed reluctance to walk away from the agreement.