Former President Barack Obama is calling President Donald Trump’s decision to pull out of the Iran deal a “serious mistake” that will erode America’s global credibility.

“The consistent flouting of agreements that our country is a party to risks eroding America’s credibility, and puts us at odds with the world’s major powers.”

Obama’s administration brokered the deal. He says Tuesday that Trump’s decision to withdraw is “misguided,” especially because Iran has been complying.

Obama also warned: “The consistent flouting of agreements that our country is a party to risks eroding America’s credibility, and puts us at odds with the world’s major powers.”

Obama says that without the deal, the U.S. “could eventually be left with a losing choice between a nuclear-armed Iran or another war in the Middle East.”

He says the deal remains a model for what diplomacy can accomplish, including when it comes to North Korea.

READ MORE: U.S. will exit nuclear agreement with Iran, Trump says