Masked gunmen stormed a hospital in this border city and engaged police in a shootout that claimed three lives before authorities retook the facility.

Six to eight assailants entered the public hospital Wednesday morning and ran into a group of state police who were escorting some prisoners for routine surgery, Tijuana Police Commander Jaime Niebla said. Two state police officers and one of the gunmen were killed.

The gunmen holed up in a ward for several hours until dozens of soldiers and federal police stormed in. Shots were heard from the building during the raid.

Soldiers were later seen taking several detainees out of the hospital with their faces covered.

Authorities said they evacuated 500 workers and patients, taking some to nearby private hospitals. There were no immediate reports of patients suffering injuries.

Officials initially said the gunmen had seized patients, but Niebla later said no hostages were taken.

A state police officer who would not be quoted by name because he was not authorized to speak to the press said the gunmen were trying to rescue a companion who was being treated in the hospital after being shot by police in a separate incident.

However Red Cross representative Fernando Esquer said he believed they were trying to free one of the prisoners.

Gangs have stormed into several hospitals across Mexico in recent years to kill injured rivals or free prisoners.

In January, President Felipe Calderon sent 3,300 soldiers and federal police to the city to hunt down drug gangs. Dubbed "Operation Tijuana," the initiative was part of a nationwide military offensive involving 24,000 troops deployed to states plagued by execution-style killings and beheadings as rival gangs fight over marijuana plantations and smuggling routes.

Drug gangs were blamed for more than 2,000 murders nationwide in 2006 and have left a particularly bloody trail in Tijuana, where more than 300 people were slain last year.

The offensive has led to hundreds of detentions including the Wednesday arrest of Nabor Vargas, a former soldier and alleged regional leader of the Zetas, a violent group of enforcers linked to the Gulf Cartel.

But despite the government crackdown, violence has continued unabated across Mexico this year with more than 700 killings blamed on drug gangs.

On Wednesday, gunmen ambushed and killed a man while he driving along the main beach-front avenue in the tourist resort of Acapulco.