The blaze was started by angry inmates late Friday evening as police entered the prison in Bengkulu, on Sumatra island, in search of a wanted inmate, local police spokesman Sudarno told AFP.
More than 250 prisoners were rescued as the fire tore through the facility, but there were five who did not make it out alive.
Boarding house fire in US kills up to six
"It's true that five prisoners died. They were trapped inside," said Sudarno, who like many Indonesians goes by one name.
"Several of the prison buildings have been damaged, but the investigation is still underway."
The five deceased have been identified, Sudarno said, while no other prisoners suffered injuries.
Footage on local television showed flames licking the walls of the prison as inmates were frogmarched from the blaze.
As Indonesia hunts down Islamic State, homegrown militants regroup
Officials were later seen carrying plastic body bags from the charred building to waiting ambulances.
Indonesia has some of the toughest anti-narcotics laws in the world, including death by firing squad for traffickers, and has launched a full-scale "war on drugs" to erase what authorities claim is a nationwide scourge.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ