Military police killed the leader of a gang that had spectacularly blasted its way into a gem-cutting plant in Brazil, before trading fire with police and making off with nine hostages who were later safely freed.

Three of the assailants died in the shoot-out in the state of Rio Grande do Sul, a military police official told AFP on condition of anonymity.

The dead included Elisandro Falcao, 31, one of the state's most-wanted men. He led a gang that specializes in robberies using explosives to target banks and automated teller machines, reports said.

The surviving attackers fled with their hostages -- one of whom was a 12-year-old girl -- into a wooded area of the town of Cotipora, with police pursuing in cars and helicopters, the official said.

At least 100 military police, backed by helicopters, worked into the night in the search for five assailants and their captives.

After an hours-long operation, police freed all nine hostages safely, but also exchanged more fire with the assailants, killing three more of them, while two police were injured, officials said.

The area where the strike was carried out is in the heart of the gem-cutting industry in Brazil, which is a world leader in exporting many semiprecious stones such as topaz, aquamarine and amethyst.

The robbers detonated dynamite to storm into the plant, then ran into police on their way out, the military police official said.

"There was an intense firefight. Three assailants died and two police were injured," Rio Grande do Sul state military chief Sergio Abreu told reporters.

Police have recovered part of the loot, but gave no figure for its value.

As they made their escape, the attackers split into two groups. One took two people who were in a bar hostage, and the other broke into a home and abducted seven people, apparently all members of the same family.

The forest where the gang fled is thick and hard to navigate, but police surrounded it, said state deputy military commander Altair de Freitas.

Helicopters and special operations teams with sniffer dogs took part in the search, he added. News reports said the remaining gang was made up of nine men armed with rifles.

Governor Tarso Genro stressed that the hostages' lives were the top priority.