A Brazilian police sniper fatally shot an armed man who held dozens of people hostage on a public bus in Rio de Janeiro after a four-hour standoff, officials said.

The hostage-taker, armed with a gun and a knife, was seen on Brazilian TV exiting the passenger bus and being immediately surrounded by police. He was reportedly arrested at the scene. Rio de Janeiro Gov. Wilson Witzel later confirmed the man had died.

All of the hostages were released unharmed, Rio de Janeiro State Military Police said.

The hostage situation began around 5:30 a.m. local time Tuesday on a busy bridge linking Niteroi to downtown Rio de Janeiro. Police shut down traffic to the bridge – leaving hundreds of vehicles lined up in both directions – and placed a sniper on a nearby perch.

BRAZIL GANG LEADER WHOSE ELABORATE DAUGHTER DISGUISE FAILED FOUND DEAD IN JAIL CELL

Federal Highway Police said the armed man, who was threatening to set the bus on fire, had been holding 37 people hostage. Negotiations were underway before the standoff ended.

At least 6 of the hostages were released during the incident, telling authorities that the man had spilled gasoline in the bus. They said the man identified himself as a policeman, although this has not been confirmed. One hostage told TV Globo he appeared "very calm" and hadn't been behaving aggressively.

CLICK HERE FOR THE FOX NEWS APP

Authorities said the man had not made any particular demands and appeared to have “psychological problems.”

The Associated Press contributed to this report.