On Wednesday afternoon, officials gathered at the downtown Washington headquarters of the Energy Department for an event more than two decades in the making: the signing of a civilian nuclear agreement between the United States and Saudi Arabia.

Two sets of American and Saudi flags were placed on stage and on the table where Energy Secretary Chris Wright was seated. A large screen beamed in his Saudi counterpart from Riyadh. After months of delay, the arrangement was finally signed.

The Saudis had won much of their wish list for the deal.

But as quickly as it was announced, it seemed to fall apart. Thursday morning, Trump said in a social media post that the deal was subject to a new condition: Saudi Arabia would have to join the Abraham Accords, an initiative dating back to Trump’s first administration that led to several Arab countries normalizing their diplomatic stance toward Israel. Trump also denied that the agreement would allow uranium enrichment.

The president, according to a source familiar with the matter, was already angry over the unveiling of the deal, which Wright had not told Trump he would be announcing.