Robert Mortby, 28, opened fire in the Rose and Crown pub in Bermondsey, south London, in front of revellers and a hen party, it is alleged.
Richard Walsh was hit twice in the abdomen, where the bullets are still lodged, while another bullet grazed the leg of his pal Christopher Green.
The Old Bailey heard Mortby fled the scene on July 28, 2012 and was still on the run until he agreed to be extradited from Spain in September last year.
Zoe Johnson QC, prosecuting, said Mr Walsh is still undergoing surgery for his wounds.
She added: “Richard Walsh had shared a joint with an acquaintance of his, this defendant Robert Mortby.”
But the court heard as they returned to the pub, Mortby and his brother entered the boozer.
The victim put his hands up and said he did not want any trouble, before being hit on the back of the head with a glass bottle by David Mortby, who was later to admit affray.
Immediately afterwards, Robert Mortby allegedly fired three times at close range, hitting Mr Walsh twice in the stomach and grazing the leg of Mr Green with the third bullet.
Although the pub was busy, no one saw who pulled the trigger and the landlord called emergency services, jurors were told.
Ms Johnson said: “The prosecution case is although Richard Walsh did not see who pulled the trigger, it is clear he was cornered by the Mortby brothers and shot by this defendant, Robert Mortby.”
Mortby, from London, denies the attempted murder of Mr Walsh and possessing a self-loading pistol with intent to endanger life.
Ms Johnson told jurors the issue was whether the victim had correctly identified the defendant as the shooter.
The trial continues.