The iron doors to the "Christ is Love" center were locked, preventing many residents from escaping, said Fire Department commandant Antonio Zavala, explaining the high death toll.
Those who died in the fire were laid out on the ground outside the center, quickly becoming the focus of emotional scenes as distraught relatives arrived to identify loved ones.
Like many low buildings in Lima, the center had two stories built in cement block and a third in wood, with metal sheets for roofing.
Some escaped the inferno by jumping from the burning building.
"I could just see smoke and hear screams," one survivor who leapt from the second floor told RPP radio.
Zavala said the blaze broke out on the first floor of the center when a patient's mattress caught fire. Officials said it may have been set alight during a fight among residents of the rehab center in this sprawling capital of about eight million people.
"So far we have information that 22 people died at the scene," said Health Minister Alberto Tejada, adding that four others died after being taken to hospitals.
At least three of the injured were in "very, very serious" condition, a Health Ministry official, Javier Correa, said.
Paramedics and firefighters rushed to the scene in Lima's San Juan de Lurigancho neighborhood, and began ferrying the injured to hospitals in ambulances and patrol cars, the Health Ministry said.
Frantic family members jostled outside, desperate for news about missing loved ones.
"I have a brother in there, and I don't know if he is dead or alive," one woman told AFP a few moments after she apparently fainted. "I keep asking but they keep telling me nobody knows anything, and to go ask at the hospital."
Sources with the Lurigancho local government said the center had been closed twice in the past for overcrowding and not meeting inspection for its business.
Maria Alca Ramos, whose cousin was treated at the center, said her family paid about $55 a month for in-patient care.
"I had a brother in there too, but three weeks ago he ran away, because they tied him up in there," she told AFP.
Asked if the center had a permit to operate, Tejada said, "apparently, it is not official."
"We are investigating," he said. "We are going to look at this circumstance after the fact, because the work is still under way to address this sad incident."