A homeless man has paid with his life after he helped save a woman taken hostage by a gun-wielding man outside a church in Brazil.

The gunman, Luiz Antonio da Silva, 49, was visiting the Sao Paulo Cathedral with the woman, who has not been named, on Friday when an argument erupted, Globo reports.

"They entered and spent some time (in the church). They seemed to be arguing… She wanted to leave. He grabbed her arm. They then left the church and he assaulted her," cathedral security guard Joao Nascimento said.

As da Silva held the terrified woman down while brandishing a pistol, Erasmo Francisco Rodrigues de Lima, 61, intervened, tackling the gunman and allowing the woman to escape.

Da Silva then shoots de Lima in the chest, but the man keeps charging, before the footage abruptly ends.

De Lima reportedly died at the scene, while the gunman was shot and killed by Sao Paulo police.