(Adds background, details on riot)

SAO PAULO, July 29 (Reuters) - At least 52 inmates died, with 16 decapitated, in a prison riot on Monday in the northern Brazilian state of Para, the state's prison authority said, underlining the struggle Brazil's far-right government faces to restore order in the country's jails.

State authorities said the riot began around 7am on Monday in a prison in the city of Altamira, and involved rival criminal gangs who took at least two penitentiary officers hostage as they battled one another.

Videos circulating online showed inmates celebrating as they kicked decapitated heads across the floor. Reuters was unable to independently verify the footage.

Elected on a tough-on-crime message, far-right President Jair Bolsonaro has benefited from a sharp drop in homicides this year. Nonetheless, endemic prison violence serves as a reminder of the ongoing public security challenges he faces in one of the world's most violent countries.

The grisly riot is the latest deadly prison attack this year. At least 55 inmates died in May during an attack in a lockup in the northern state of Amazonas. In 2017, weeks of violence in Amazonas resulted in 150 prison deaths as local gangs backed by Brazil's two largest drug factions went to war.

As Brazil's incarcerated population has surged eight-fold in three decades to around 750,000 inmates, the world's third-highest tally, its prison gangs have come to wield vast power that reaches far beyond prison walls.

Originally formed to protect inmates and advocate for better conditions, Brazil's prison gangs are now involved in bank heists, drug trafficking and gun-running, with jailed kingpins presiding over their empires via smuggled cellphones.

In the violent northeast, prison gangs have grown powerful moving cocaine from Colombia and Peru along the Amazon's waterways to the Atlantic coast, where it heads to Africa and Europe. Murderous disputes often arise as they clash over territorial control.

Bolsonaro's government has proposed moving powerful incarcerated drug lords to federal lockups, and building more prisons at the state level. However, with the vast majority of prisons run by Brazil's overstretched state governments, Bolsonaro is limited on what he can achieve from Brasilia.

In February, Justice Minister Sergio Moro unveiled his signature crime-fighting bill, which includes proposals to toughen prison sentences and isolate gang leaders in maximum-security lockups.

That bill, however, has struggled in Congress, with the government prioritizing its pension reform bill. (Reporting by Marcelo Rochabrun and Eduardo Simoes; Editing by Gabriel Stargardter, Christian Plumb and Dan Grebler)

Our Standards: The Thomson Reuters Trust Principles.