SANTA CRUZ — In a town besieged by an uncommon spate of violence in recent weeks, the most horrifying turn came Tuesday: Two Santa Cruz police officers were gunned down and the suspect shot dead.

The deaths of detective Sgt. Loran “Butch” Baker, a 28-year veteran, and detective Elizabeth Butler, a 10-year veteran, are the first in the line of duty in the city’s history.

“This is the darkest day in the history of the Santa Cruz Police Department,” police Chief Kevin Vogel said, adding earlier, “Our department is in mourning. This is a horrific day. We lost two exceptionally fine officers today.”

The deadly confrontation unfolded at 3:30 p.m. at a house in the 800 block of North Branciforte Avenue. Police were investigating a possible domestic violence or sexual assault when the suspect fired at them, hitting the two officers, who were found dead outside the house.

Police then set up a perimeter, and a multi-agency team worked to secure the North Branciforte area, including three schools, to find the suspect identifed as Jeremy Peter Goulet, 35. They encountered Goulet on nearby Doyle Street about 30 minutes later, and a barrage of gunfire followed.

“Gunshots ensued between Goulet and the officers. Goulet was killed at the scene,” Santa Cruz Sheriff Phil Wowak said.

Baker leaves behind a wife, two daughters and a son who works for the police department.

Wowak said his office will take over patrol operations for the police department for the time being. He also said his department would be assuming control of the criminal investigation per the department’s critical incident protocol, which includes cooperation of the Santa Cruz police, the Sheriff’s Office and the District Attorney’s Office.

“My heart goes out to those who were involved,” Wowak said.

Megan Kausch, a Capitola resident, was sitting outside Whole Foods reorganizing her purse when police swooped in.

Police came up, chasing a suspect who appeared to have two guns. She heard gunfire. She ducked down and when she looked up saw the gun smoke.

“I’ve never been so close to a real shooting. It was so loud, so many bullets back and forth,” Kausch said.

Police were on a citywide manhunt for several hours after the initial shooting, not knowing if there were other suspects on the loose. The FBI joined the investigation just after 4 p.m., as well as law enforcement from the Sheriff’s Office, Capitola and Watsonville.

Vogel rushed out of a City Council meeting upon hearing the news.

City Manager Martin Bernal pulled Mayor Hilary Bryant out of the council meeting to discuss the shooting. Several people at the council meeting were crying.

As they investigated the shooting, police issued an all-points bulletin for Goulet, who they said had three weapons registered to him, including a .40-caliber semi-automatic Sig Sauer. He had been arrested by Santa Cruz police Friday on suspicion of disorderly conduct but bailed out, according to arrest records. He listed his occupation as a barista.

According to an employee at a harbor coffee shop, Goulet had been a barista there until Saturday, when he was fired because of an incident Friday night involving an employee of the coffee shop.

Goulet, who lived in the 800 block of North Branciforte, reportedly broke into the co-worker’s house Friday night and made inappropriate sexual advances toward her. The barista filed a police report and talked to police as late as Tuesday afternoon.

The coffee shop employee, who spoke only on condition of anonymity, said workers thought Goulet was “unstable” and “weird.”

Santa Cruz police closed the coffee shop shortly after the first shooting, telling employees they were concerned because of Goulet’s involvement in the Friday incident.

Goulet was convicted in 2008 on sex and gun charges in Portland, Ore., according to an article on the Oregonian newspaper’s website. He was found guilty of peeping at a 22-year-old woman as she showered in her condo and of carrying a concealed weapon, which discharged after Goulet was confronted outside by the victim’s boyfriend, according to the article. He was put on probation in that case but decided to serve a two-year jail sentence because he couldn’t get along with his probation officer, the article said.

Goulet had also recently lived in Berkeley, records show.

Goulet’s former neighbor, who declined to give her name, said, “He had some anger issues. He’d have his brother stay, and they’d get in huge arguments.”

The shootings sparked chaos on city streets. About 10 minutes after the first shooting, police were called to Stanford Avenue for a victim who said he was grazed by a bullet but was declining medical attention.

Santa Cruz resident Charlie May was inside his home on North Branciforte when the incident erupted, with dozens of police cars descending on the area.

“I actually went out to take a look, and they shooed us all back,” May said.

Melissa Stevens was waiting at Doyle Street, where the street was blocked off, for her son, who was on lockdown at the Midtown Montessori School on Branciforte. Other schools on Branciforte also were on lockdown. About 7 p.m., buses arrived to start taking students to the county building to meet up with their parents.

“I’m sort of freaked out,” Stevens said. “Everyone is safe, but as long as there is a shooter on the loose, I don’t know what I should do.”

Earlier, several parents stood on Water Street near the crime scene, waiting for any information on when and where they could pick up their children.

“I heard 40-50 very fast gun shots by the school where our daughters are,” Rebecca Green said as she stood with fellow parent Renata Russo. “I know nothing about guns — it only sounded like that many shots to me.”

The shooting comes after several weeks of violence in Santa Cruz, including a downtown murder, the shooting of a UC Santa Cruz student and the rape of another woman on campus. There was also a violent robbery at a grocery store and a home-invasion robbery.

Some parents, like Russo, said they were frustrated with the ongoing crime in the city.

“What is the city doing about crime in this town?” Russo asked. “This is the last thing I’d ever thought would happen.”