LIMA, Peru — Thousands of illegal gold miners battled police for control of a regional capital in the Amazon basin on Wednesday and at least three people were killed by gunfire.

Outnumbered riot police fired tear gas against miners who wielded clubs and rocks and tried to seize strategic facilities. The miners are fighting government efforts to regulate small-scale gold extraction, which is ravaging the rain forest, contaminating it with tons of mercury.

Interior Ministry spokesman Victor Calderon said it was unclear whether police fired directly on rioters in Puerto Maldonado, a boomtown at the confluence of two jungle rivers in a region popular with ecotourists.

After talks failed with a government delegation, at least 12,500 miners had attempted to seize public buildings, markets and the airport in the city, said Madre de Dios regional President Jose Luis Aguirre.

“The situation is untenable. You can hear gunshots throughout the entire city,” he said.