A San Francisco police officer and a suspect were both critically wounded in a Halloween night gunbattle in a popular neighborhood for holiday celebrations, officials said Wednesday.

Shots erupted when the 41-year-old officer approached a parked car in the city's Castro neighborhood to check on reports of a suspicious vehicle, San Francisco police Sgt. Michael Andraychak said.

The neighborhood is a popular Halloween night gathering spot that has attracted as many as 250,000 people in the past to city-sanctioned parties. But San Francisco stopped sponsoring Halloween events in the Castro after nine people were shot in 2006, a culmination of other violent incidents over the years.

The neighborhood is loaded with popular gay bars and other nightspots and still attracts many Halloween revelers. It's unclear how many partyers were in the area during the shooting that occurred shortly after midnight, Andraychak said.

He declined to release the names of the suspect or the officer, a nine-year veteran of the department who was undergoing surgery. The officer is a crime-scene investigator who was assigned to patrol on a busy Halloween night, the sergeant said.