This is the moment an armed robber is left writhing in agony on the pavement after being gunned down by a building foreman he tries to intimidate into handing over cash.

The criminal, named locally as 40-year-old Ricardo Palazzo, pulled out his weapon after spotting Pedro Gonzalez sitting in an expensive-looking 4x4 opposite a building site.

CCTV cameras showed him demanding his intended victim open his car door and even banging on the glass with his pistol when he didn't get him to buckle immediately.

The robbery attempt was captured on CCTV, as Ricardo Palazzo tried to rob Pedro Gonzalez

CCTV cameras showed him demanding his intended victim open his car door and even banging on the glass with his pistol when he didn't get him to buckle immediately

Instead of cash he ended up getting lead in his groin and a shoulder as his target fought back with a weapon he had hidden in his vehicle and blasted him three times to the ground.

The incident happened in Caballito, a neighbourhood of the Argentinian capital Buenos Aires.

At first it appeared the armed robber had been shot dead.

But he began to move as the construction worker dialled 999 and onlookers rushed over to see what had happened.

Last night - as 62-year-old Mr Gonzalez was freed after several hours in custody by a judge who ruled he acted in self-defence - it emerged he had more than £10,000 in workers' wages on him when he was targeted.

The revelation led to speculation the robbery was not the opportunistic crime the CCTV cameras appeared to suggest.

Instead of cash he ended up getting lead in his groin and a shoulder as his target fought back with a weapon he had hidden in his vehicle and blasted him three times to the ground

As well as a 9mm Bersa Thunder pistol, the same weapon the building foreman used, police confiscated a grenade from a rucksack the armed robber was carrying.

The 50 men due to receive their wages from the intended victim have now been paid.

Mr Gonzalez's lawyer Mariano Fragueiro Frias said: 'The investigating judge took more than ten statements from witnesses who were at the scene when this incident took place, before and after the shots.

The judge said of Gonzalez: 'He acted in self-defence. He was attacked by a man with a gun who was pointing his weapon at him'

'It was clear that my client was the one who called the police and the paramedics.

'He acted in self-defence. He was attacked by a man with a gun who was pointing his weapon at him.

'He replied with his own firearm. He has a firearms licence.'

One social media user wrote: 'It's so gratifying to see this video.'

Another added: 'This 62-year-old man deserves the nickname Badass.'

The 2012 Hollywood film Bad Ass, starring Danny Trejo and Charles S. Dutton, focuses on a Vietnam veteran who becomes a local hero after saving a man from attackers on a city bus.