Armed police shot Mark Duggan as he got out of a minicab holding a loaded gun and appeared to be about to shoot, a court has been told.
The situation, which led to rioting in August last year, was "as dangerous a position as possible" for police marksmen, Snaresbrook Crown Court heard.
At the trial of the man accused of passing the handgun to Mr Duggan, the jury heard he collected it just 15 minutes before he was shot dead on August 4, 2011.
The 29-year-old's death in Tottenham, north London, sparked riots that swept across the capital and the country.
Kevin Hutchinson-Foster is on trial accused of passing the gun to Mr Duggan that same day. The 30-year-old is charged with "selling or transferring a prohibited firearm" to Mr Duggan between July 28 and August 5, 2011.
Hutchinson-Foster, of no fixed abode, denies passing the BBM Bruni Model 92 handgun to Mr Duggan, contrary to the Firearms Act 1968.
The court heard that Mr Duggan had been under surveillance on August 4, as well as the previous day. The prosecution claims he travelled in a minicab to collect the gun from Hutchinson-Foster in Leyton, east London, before continuing to Tottenham.
Opening the case, prosecutor Edward Brown QC said Mr Duggan was followed by armed police who decided to carry out a "hard stop".
"The armed police surrounded the cab but as Mr Duggan got out he was seen to have the gun in his hand," he said. "The police marksmen were in no doubt that this was as dangerous a position as possible - gun in hand, and he was seen to start to bring it round as if to shoot."
Mr Duggan was shot, Mr Brown said, adding: "He fell to the ground fatally injured. From that moment until the ambulances and helicopter ambulance arrived they sought to resuscitate Mr Duggan but to no avail."