Indonesian security forces have rounded up most of the inmates who escaped during a mass breakout from an overcrowded prison on Sumatra island, police said.

About 200 inmates broke out of the jail in Pekanbaru, on Sumatra island, after they were let out of their cells to pray on Friday.

Almost 80 were quickly recaptured after the incident, and on Saturday the majority had been rounded up, officials said.

"So far, 171 inmates have been recaptured or surrendered willingly, we are still unable to determine the exact number of the inmates who escaped," local police spokesman Guntur Aryo Tejo told AFP news agency.

Amateur footage broadcast on local TV stations showed scores of men, some wearing sarongs, scurrying through the gates of the Sialang Bungkuk prison on Friday, with no sign of officials in pursuit.

Most prisoners were recaptured while still near Pekanbaru.

Dozens of the escaped inmates headed directly to another prison where they handed themselves in.

Tejo said the inmates told the police they decided to escape due to inhumane conditions in the prison.

The male-only prison has a capacity of 300 people but was holding 1,870 inmates, with only five guards and a porter on duty at any one time, said director general of prisons, I Wayan Dusak.

"They also complained about unfair treatment by the prison guards," Tejo said.

READ MORE: Indonesia - Manhunt under way after mass jailbreak

More than a thousand inmates who did not escape the prison were refusing to return to their cells unless the head guard was replaced.

Jailbreaks are common in Indonesia, where inmates are held in often unsanitary conditions at overcrowded prisons.

There was a spate of breakouts in 2013, including one where about 150 prisoners - including "terror" convicts - escaped from a jail on western Sumatra island.