Stuart Everton, 20, had earlier unsuccessfully tried to rob two building societies before escaping with pounds 1,800 from the bank.
He was ambushed in an alley by two robbers, who grabbed his gun and forced him to hand over the money, Tony Docking, for the prosecution, alleged.
The muggers then presented themselves to police as courageous citizens who had chased the robber. They were even prepared to give evidence against him.
The truth only emerged when police checked Everton's story and found the robber had, indeed, been robbed after the raid at Barclays Bank in Barnet, north London, on 3 August this year.
While Everton was inside the bank holding staff at gunpoint and forcing them to hand over cash, the two muggers were calmly waiting for him outside.
It was even possible, the court heard, that the muggers planned to rob the bank themselves but when they got there found Everton had beaten them to it.
Then 'they simply followed him, mugged him and pretended they had given chase and lost him', Mr Docking said.
Two men arrested later are awaiting trial on charges connected with the mugging.
Everton pleaded guilty to three robberies and related firearms charges and asked for two earlier attempted robberies to be taken into consideration.
He was sentenced to two years' probation and ordered to do 80 hours' community service.Reuse content