For months, US spies had been monitoring Venezuelan President Nicolas Maduro's every move.
A small team, including one source within the Venezuelan government, had been observing where the 63-year-old slept, what he ate, what he wore and even, according to top military officials, "his pets".
Then, in early December, a planned mission dubbed "Operation Absolute Resolve" was finalised. It was the result of months of meticulous planning and rehearsals, which even included elite US troops creating an exact full-size replica of Maduro's Caracas safe house to practise their entry routes.
The plan - which amounted to an extraordinary US military intervention in Latin America not seen since the Cold War - was closely guarded. Congress was not informed or consulted ahead of time. With the precise details set, top military officials simply had to wait for the optimal conditions to launch.
They wanted to maximise the element of surprise, officials said on Saturday. There was a false start four days earlier when US President Donald Trump gave approval, but they opted to wait for better weather and less cloud cover.
"Over the weeks through Christmas and New Year, the men and women of the United States military sat ready, patiently waiting for the right triggers to be met and the president to order us into action," General Dan Caine, the nation's highest-ranking military officer, told a news conference on Saturday morning.
'Good luck and godspeed'
The order from the president to begin the mission finally came at 22:46 EST on Friday (03:46 GMT on Saturday).
"We were going to do this four days ago, three days ago, two days ago, and then all of a sudden it opened up. And we said: go," Trump himself told Fox & Friends on Saturday, hours after the overnight raid.
"He said to us, and we appreciate it... good luck and godspeed," Gen Caine said. Trump's order came shortly before midnight in Caracas, giving the military most of the night to operate in darkness.
What followed was a two-hour-and-twenty-minute mission by air, land and sea that stunned many in Washington and around the world.
In terms of scale and precision, it was virtually unprecedented. And it drew immediate condemnation from several regional powers, with Brazil's President Lula da Silva saying the violent capture of Venezuela's leader set "yet another extremely dangerous precedent for the entire international community".
Trump did not follow the mission from the White House situation room. Instead, he was surrounded by his advisers at his Mar-a-Lago club in Palm Beach, Florida, where he watched a live stream of the operation flanked by CIA Director John Ratcliffe and US Secretary of State Marco Rubio.
"It was an incredible thing to see," Trump said on Saturday. "If you would have seen what happened, I mean, I watched it literally like I was watching a television show. And if you would've seen the speed, the violence... it's just, it was an amazing thing, an amazing job that these people did."
Donald Trump / TruthSocial
Donald Trump / TruthSocial
Donald Trump / TruthSocialSoon, videos showing numerous aircraft in the skies - and others showing the apparent aftermath of explosions - began to circulate widely on social media. One showed a convoy of helicopters flying at low altitude over Caracas as smoke rose from apparent detonations.
"We woke up at around 01:55 to the roar of explosions and the hum of planes flying over Caracas," one witness. Daniela, told the BBC. "Everything was plunged into absolute darkness, illuminated only by the flashes of nearby detonations."
She added: "Neighbours were messaging in the condominium group chat, all confused and unaware of what was happening [and] frightened by the blasts."
BBC Verify has examined a number of videos showing explosions, fire and smoke in locations around Caracas to identify exactly which sites were targeted.
So far, it has confirmed five locations including Generalissimo Francisco de Miranda Air Base, an airfield known as La Carlota and Port La Guaira, Caracas' main conduit to the Caribbean Sea.

BBC