For the second time in his presidency, President Donald Trump stared, horrified at pictures of children killed in a chemical attack in Syria.

And for the second time in his presidency, those visceral images helped propel Trump toward military strikes in a country he sees as a trap for the United States.

At times, the lead-up to Friday's strikes was orderly — a traditional decision-making process for an unconventional president. He sought the input of national security advisers and convened Situation Room meetings. He consulted with allies, who shared his anger at the photos emerging from Syria of children and adults apparently killed or sickened by poisonous gases.

But at other moments, the chaotic nature of Trump's presidency broke through. He hinted at his plans in bellicose and at times confusing tweets. And he seethed over the legal threats springing up around him, including a raid on his longtime lawyer's home and office.

Through it all, U.S. and Western officials said it was clear Trump intended to take military action. Discussions with France and Britain were focused not on whether to strike, but how to do so in a way that went beyond "punishing" the Assad regime for the attack and instead would degrade its ability to use chemical weapons in the future, according to two Western diplomats with knowledge of the discussions.

The diplomats and U.S. officials insisted on anonymity because they were not authorized to publicly discuss the private discussions.

Trump attended multiple briefings per day, according to officials, and sat in on most high-level meetings in the Situation Room. Advising Trump on Syria was John Bolton, the newly installed national security adviser with a militaristic and hawkish reputation, and Defense Secretary James Mattis, who sought to ensure that military action was linked to a broader strategy.

At a Cabinet meeting Monday, Trump condemned the "atrocious attack," promising speedy action.

On Tuesday, Trump spoke to both French President Emmanuel Macron and British Prime Minister Theresa May. Officials from all three countries huddled in Washington as the allies tried to determine who would participate and what a potential strike would look like.

But Trump still had no firm commitment that the allies would join him. While all three Western countries believed chemical weapons had been used, international inspectors had not reached the site of the attack and it was unclear how much evidence their governments could put forward.

As negotiations over the Syria response continued, Trump was pummeled by the surprise raid of his personal attorney Michael Cohen's home and office and the new book from fired FBI director James Comey. He was particularly incensed by the raid, which was prompted in part by a referral from special counsel Robert Mueller, whose investigation into Russian meddling in the 2016 election shadows the president.

As the deliberations dragged on, Trump vented on Twitter. He threw the process into confusion Wednesday when he tweeted at Russia to "Get ready" because missiles "will be coming, nice and new and 'smart!'" After sustaining criticism for appearing to reveal his strategy, Trump tweeted the following day that he had not signaled the timing of an attack, adding: "Could be very soon or not so soon at all!"

By Thursday, Trump made the final decision to authorize the strike. Officials said the plan to hit three targets in Syria was aimed at avoiding "collateral damage," including Russian assets.

Asked why the president had acted now, given the Assad government is alleged to have used chemical gas at least 50 times, administration officials said they believed there was "incontrovertible evidence" that chemical weapons had been deployed. Much of the evidence comes from witness testimony, as well as video and photos shot by aid workers, victims of the attacks and unspecified additional intelligence about barrel bombs and chlorine canisters found in the aftermath.

Officials said Trump was also frustrated that economic, diplomatic and political efforts aimed at convincing Assad that using chemical weapons was not in his interest had failed.

For a full day after Trump made his decision, the administration managed to keep its intentions largely under wraps. The tweets stopped and White House officials suggested to journalists that Trump might spend Friday night dining at his hotel in Washington.

But at 9:01:30 p.m. Friday, Trump delivered a televised address to the nation announcing the strikes were underway.

As the missiles rained down, one administration official explained that, over the course of this week, the president had tweeted his intention to the American people. Now, they said, his orders were being carried out.

By Saturday morning, Trump celebrated a "perfectly executed strike."

"Mission Accomplished!" he wrote.