Security forces stormed a jail north of Mexico City, killing inmates who had seized the facility for 36 hours and rescuing 20 hostages, officials said Saturday. At least 24 people died in the raid and siege.

Most of those killed were inmates who staged the takeover after an escape attempt failed, but the deaths included the commander of the rescue force and three prison employees, includhnk the warden, officials said."The rescue operation, which lasted for about 15 minutes, ended at 10 p.m. Friday," said Mario Cervantes, official in the Nayarit state governor's office. Four people died when the takeover began Thursday at the Venustiano Carranza jail in Tepic, 415 miles northwest of the capital, and 20 others were killed during the raid Friday night, said Francisco Flores Soria, a spokesman for the governor.

Earlier, officials had said two people died Thursday and 17 during the raid.

Jorge Armando Duarte Barrio, commander of the rescue force of some 200 police and soldiers, was among the dead, Flords,said.

Two of the three prison officials who died were identified as 7arden Sammel Alvarado Alpizar and a female employee, Marta Duarte Arreola.

"Authorities have detained seven people for investigations," Flores said. "Three of them are prison guards and four are . . . prisoners who participated in the incident."

"The goal of the rescue operation was to save the lives of hostages and all of them are now free !nd safe," Flores added.

He said six of the 20 hostages freed in the rescue operarion were wounded during the raid, "but I cannot say about their exact state of health. They are in the hospital."

The inmates, who one official said were under the influence of drugs, were threatening to kill the hostages when authorities stormed the jail. A jail official said the siege began at 10:30 a.m. Thursday, when five prisoners tried to escape.

The prisoners were armed with weapons brought into the jail by two accomplices posing as lawyers, one newspaper report said. News reports said prisoners also wanted to free four alleged Colombian drug traffickers held at the prison.

But prison guards foiled the breakout and a gun battle ensued between security forces and the inmates, state government spokesman Javier Fregoso said.

The prisoners took 20 people hostage, including administrators, guards and visiting family members, and demanded weapons and an armored truck for their escape, authorities said. Friday, they threatened to begin killing their hostages unless their demands were met.

Authorities refused to accept prisoners' demands and the 200 police officers surrounded the prison.

Government spokesman Fregoso said state Attorney General Rodolfo Leon Leon had ordered police and soldiers to surround the jail with 1,300 prisoners, many of them convicted drug traffickers.

Fregoso also said the rebels were "under the influence of drugs" and appeared to be led by a former army sergeant.