Some of the victims were critically wounded in the 6 p.m. attack, San Diego Police Chief Shelley Zimmerman said at a media briefing.
Three officers opened fire on the suspect after a helicopter hovering over the suburban community of University City spied the shooter appearing to reload the weapon.
The gunman was fatally shot.
A witness told KFMB-TV he heard the gunfire and saw the shooter lounging by the pool, drinking a beer in one hand and brandishing the weapon in another.
It’s unclear if the suspect is a resident of the apartment building. He was not immediately identified.
This is a developing story and will be updated.