A man brandishing a fake gun took dozens of hostages on a bus in Brazil and threatened to set the vehicle on fire with petrol before police shot him dead in a four-hour standoff broadcast live on television.

All hostages were freed unharmed in the confrontation, which unfolded on an eight-mile bridge linking Rio de Janeiro to the Niteroi area across Guanabara Bay.

The seized bus was travelling from Sao Goncalo, a community struggling with poverty and violence that lies across the bay.

Many people use the bridge to travel to and from work in Rio, and hundreds of vehicles were backed up as police closed lanes and tried to get control of the situation.

The man took 37 people hostage on the bus at around 5.30am as commuter traffic was increasing.

He released six hostages, then later he stepped out of the bus, threw an object resembling a bag and was shot by a sniper.

The gunman’s intentions were unclear and he did not make any particular demands, according to police.

The standoff was broadcast live on Brazil’s TV Globo, riveting Brazilians in a nation accustomed to high levels of crime.

Police escort the bus  away
Police escort the bus away (Leo Correa/AP)

Wilson Witzel, governor of Rio de Janeiro state, praised police, saying the hostage situation was high-profile but that armed criminals are regularly “terrorising” people out of sight of most Brazilians.

“If the police could do their job and shoot people with rifles, so many victims would be spared,” he said on TV Globo.

The governor, a former marine, has argued in favour of using snipers on helicopters to shoot armed criminals in Rio’s crime-ridden slums.

He is a political ally of President Jair Bolsonaro, whose successful election platform last year included a pledge to get tough on crime.

Wilson Witzel speaks during a press conference
Wilson Witzel speaks during a press conference (Leo Correa/AP)

Rio’s elite police force, known as BOPE, had taken charge of negotiations with the hostage-taker while a sniper was placed near the scene.

Several shots were heard when police killed the man. Journalists and others in the area ducked to the ground.

Some passengers who were freed by the assailant told police he had poured petrol in the bus and was threatening to set it on fire. However, Hans Moreno, one of the hostages, said on TV Globo that the man had appeared “very calm”.

At one point, the gunman freed a hostage who only managed to walk a few metres towards police before passing out on the ground and being taken to an ambulance.