The wounded officer was hospitalized in stable condition, the city reported.
Other details, including the names of the San Luis Obispo officers and the gunman, weren't immediately released.
Victoria Torres, 21, told the San Luis Obispo Tribune that she was upstairs in her bedroom when she heard “a very loud knocking" at an apartment across from her.
“I don’t know if it was the police or what,” she said. “I always hear noises here so I didn’t think anything of it until I heard the gunshots.“
She looked out her window and saw a police car, then walked downstairs and looked out another window.