The blaze was started by angry inmates yesterday 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.
"It's true that five prisoners died. They were trapped inside," said Sudarno, who like many Indonesians goes by one name.
The five deceased have been identified, Sudarno said, while no other prisoners suffered injuries.
More From This Section
Footage on local television showed flames licking the walls of the prison as inmates were frogmarched from the blaze.
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.