A manhunt is under way in Indonesia's Sumatra island after scores of prisoners escaped from an overcrowded jail.

Hundreds of police and soldiers were deployed near Sialang Bungkuk Prison in Pekanbaru, the capital of Riau province, and were blockading roads to the capital and other provinces, according to Wayan Dusak, a justice and human rights ministry official.

Officials said the escape occurred when prisoners tore down a gate near a mosque in the prison complex, overwhelming the six guards on duty after being allowed out of their cells to take part in Friday prayers.

Local police spokesman Colonel Guntur Aryo Tejo estimated the number of prisoners who escaped at 200 to 250, of whom 130 had been recaptured.

Some surrendered while others were captured by police or residents, Tejo said. He added that some were reportedly beaten by residents who found them trying to steal their motorbikes.

MetroTV showed dozens of men running from the prison and some being captured by police.

The prison, which has a capacity of 361, is holding more than 1,870 people, Tejo said.

"It seemed that many of the inmates alleged that there was discrimination in treatment of those accused of general crimes compared to special ones," Tejo said, referring to officials and others accused of corruption who allegedly received better treatment.

Inmates had complained about their treatment in the jail and accused some guards of being violent, said Ferdinand Siagian, head of the regional office of the law ministry.

The issue of overcapacity in most prisons in Indonesia has reached a chronic level, resulting in poor service and frequent riots.

In March 2016, riots among prisoners in Bengkulu Prison left five inmates dead and the prison building on fire.