Two police officers were beaten to death and a civilian was fatally shot when an operation targeting illegal logging went badly wrong, Mexican authorities said.

The incident unfolded Tuesday in Tlalamac, a community in the mountains of the central state of Mexico.

State police were accompanying personnel from the Probosque forest service to investigate reports of illegal logging, the Mexico state Attorney General's Office said in a statement.

Under circumstances that remain unclear, an area man was wounded by gunfire and his neighbors reacted by attacking the Probosque employees and police, the state AG's office said.

Within minutes, the police found themselves surrounded by dozens of residents armed with sticks, stones and firearms. The mob seized five of the cops and dragged them to a nearby residence, where the officers were severely beaten.

More than 150 state police rushed to the scene and demanded the release of their comrades.

When the residents refused, the police mounted a rescue operation, the official statement said.

Besides the two officers killed, eight others suffered significant injuries, while the civilian whose shooting ignited the clash died on the way to the hospital.

The state AG's office vowed that those responsible for the violence would be subjected to "the full weight" of the law. EFE