An American tourist who fought a gunman after being shot in a botched robbery was jailed for swearing at a policeman.

Joe Ianco, 54, was locked up in the Special Tourist Support Police Station in Leblon, Rio de Janeiro, after allegedly losing his temper and swearing at investigators.

Having fought the assailant, Anderson Cardosa, 43, at the scene of the crime, the American went after his attacker again in the station and was jailed for an outburst officers as they tried to calm him down.

Scroll down for video

Joe Ianco, 54, is pictured walking from a police car with blood on his cheek and on his shirt

The victim was with his American friend, Michael Bottari, 57, when the two were held up at gunpoint in the foyer of an apartment building in Ipanema, where they have been staying during Rio's New Year celebrations.

Cardosa turned up on a bicycle around 10am just as the tourists were entering the building.

Images from security cameras, shown on Globo TV, capture the moment the thug surprises the men as he pushes open the glass doors, points the gun and demands their watches, mobile phones and wallets.

During the terrifying ordeal both men, who are believed to be from New York, can be seen putting their possessions on a lobby chair.

But the gun-wielding robber appears agitated and shoots at the tourists nonetheless.

According to the victims the gun misfired each time, as it didn't work properly and the bullets 'left the barrel without any force'.

Mr Bottari said: 'We were going to try to talk to the assailant, but he cocked his revolver and fired four times.

'Luckily, we were not hit. We could have died.'

Mr Ianco is seen on CCTV holding his hand out while trying to talk to the thief and flinching each time the trigger is pulled.

Mr Bottari is captured taking refuge in the lift then darting across the corridor and out through a side door.

A few seconds later he appears in the street at the front of the building and hastily beckons Mr Ianco to join him.

As Mr Ianco exits the building, the gunman, who is wearing red and white shorts, follows and brandishes his weapon before attempting to escape on his bike.

But Mr Ianco, who is a marathon runner, bravely chases after his assailant.

In the scuffle, not seen on camera, Mr Ianco is said to have caught up with the bandit and was hit on the head with the butt of the gun during the fight.

Taxi drivers in the vicinity tried to intervene and the criminal is filmed shortly after the fight, trying to get away while still pointing the gun as people run for cover.

Joe Ianco, left, and his friend Michael Bottari, 57, who were attacked by Anderson Cardosa

Cabbie, José Atico, who was held up by the gunman, said the fight between the American and the suspect lasted just over 30 seconds.

The criminal was caught by cops who happened to be driving past.

Mr Atico said: 'I was standing at the taxi point when Cardosa came up behind me and aimed the gun at the police.

'It was very fast, I just hoped the gun was a toy. I prayed the cops wouldn't shoot.

'An officer came behind him and grabbed his hands.'

As the criminal was pinned down by cops on the steps of a nearby building, Mr Ianco, with blood on his face and shirt, is filmed angrily thumping and stamping on the head of the hoodlum.

Agents pull him away but the American returns to give his assailant another kick.

He is warned off and pushed away by another officer.

Gunman Anderson Cardosa, 43, in Brazil

According to police both Mr Ianco and Cardosa suffered bruises and minor injuries during their fight and were taken to Miguel Couto Municipal Hospital in Gávea.

The men were released in the afternoon.

Mr Ianco was filmed arriving at the police station with his white shirt stained with blood.

Shortly after, the accused was brought to the same station for questioning and identification.

According to witnesses, Mr Ianco tried to attack Cardosa again in the police station.

He was restrained and warned to calm down.

The tourist said he had not 'come to Rio to be robbed'.

An inspector responded sharply with 'this happens in many places around the world' and Mr Ianco 'should keep quiet'.

According to detective Valeria Aragão, Mr Ianco's reaction was 'disproportionate' and 'deliberate'.

He is said to have sworn and shouted at an officer who was trying to calm him down.

Detective Aragão said: 'Joe Ianco's behaviour was not done in the heat of the moment.

'He was deliberately rude, disrespectful as we believe he intended to offend the police officer.'

She added this was something no officer in Brazil would tolerate.

Mr Ianco was locked up for swearing at Brazilian officers who were dealing with his case

After a few hours behind bars for contempt, Mr Ianco was released late Friday evening.

It is not known whether he will be allowed to leave Brazil until his case is heard by the Special Criminal Court.

The Americans have been in Brazil since Boxing Day and are meant to be returning to the States this Sunday.

The tourists' stolen goods, including two Rolex watches, were recovered and returned.