Fire raced through a hotel for the elderly and mentally retarded at this seaside resort Saturday night, killing 23 persons, some of whom apparently locked themselves in their rooms in the panic and confusion.

Some of the residents returned to their rooms at the Brinley Inn after finding that the blaze had cut off a stairway that was the only escape route they had been taught in fire drills, one official said today.

"Every door I kicked in, I found a body," said firefighter Jeffrey Ralston, who arrived at the home to find it engulfed in flames shortly before midnight. "They must have panicked and bolted themselves into their rooms."

Fifteen people managed to escape from the 3-1/2-story, wood-frame building. One person was under intensive care in a local hospital.

Monmouth County prosecutor Alexander Lehrer declined today to speculate about the cause of the blaze, which he said was under investigation by his office and state and local police.

The blaze has raised questions about the state's practice of referring the elderly and retarded to facilities unlicensed by health or social service agencies. According to Lehrer, a number of persons had been referred to the Brinley Inn by the Monmouth County Welfare Board and 11 referred by the New Jersey Division of Mental Retardation. Their ages ranged from 26 to 81, he said.

The Brinley Inn was not licensed by the state health department as a facility for persons unable to care for themselves. However, Lehrer said, it was licensed as a hotel by the state Department of Community Affairs, which inspects such facilities once every five years.

Lehrer said the inn employed two live-in staffers. Neighbors said one was the manager, the other the cook.

Smoke detectors and alarms all worked, he said. The building had no sprinkler system.

"The entire thing was over and those people were dead within 10 minutes," said dentist Paul Laden, who lives across the street from the hotel.

He said the survivors spent two hours in his home until arrangements could be made to treat them at a hospital and then to find them shelter for the night.

Laden's wife, Diane, said one of the survivors, the resident manager, complained to her that the residents "wouldn't come" when she tried to help them escape.

"Even in the fire drill, I had a hard time getting them to come," Mrs. Laden quoted the manager as saying.

Neighbors today recalled seeing a small curl of smoke from the basement burst into flame that enveloped the front of the hotel. Then they heard alarms -- and screams.

"There were screams from the windows. We heard yelling, screams and hysterics," said Patrick O'Connell of New York. "I felt like a coward, but I couldn't do anything."

Minutes later, after a muffled explosion, billows of smoke poured through the building.

As fire trucks from four communities pulled up alongside the inn, the smoke and heat made it impossible to get inside.

One neighbor, Rose Ann Latorre said, "I was putting my kids to bed at about 11 o'clock when I heard the alarm. I heard the explosion right afterward. Within five minutes there were nothing but flames, and the cook from the Brinley Inn was running into our place, crying hysterically saying, "I can't get them out of there. No one can get them out of there.'"

According to Bradley Beach Fire Chief Ted Bianchi, the fire raged out of control for 45 minutes -- "and when we got it under control there wasn't anybody in the building alive."

Gene Wilkins, director of Monmouth County First Aid Squads, said the hotel routinely conducted two fire drills a month, but residents were only shown how to get out the front door. The fire escape is in the back of the building.

"They went to the front door as they'd been told," he said. "You've got mentally retarded people . . . If you show them two or three exis, what do they remember? If you show them one, they'll remember.

Wilkins said it appeared many of the residents went back to their rooms and locked themselves in after fire cut off the front stairway.

Firefighters said many of the elderly residents who went to the fire escape area were afraid to go down it.

"People wouldn't come down. We couldn't coax them down," said fireman Mitch Rosen.