A police officer in Sacramento, Calif., died late Wednesday hours after a suspect opened fire on her and other officers while responding to a domestic violence call.

Police later identified the slain officer as 26-year-old Tara O'Sullivan. The suspected gunman surrendered to authorities after he'd barricaded himself inside a home for nearly eight hours, The Sacramento Bee reported.

O'Sullivan had been working for the city since January 2018, according to city records cited by the paper. She was part of the first class of graduates of Sacramento State's Law Enforcement Candidate Scholars program in 2017 and went on to the Sacramento Police Academy.

Several officers were on a domestic disturbance call, helping a woman collect her belongings and leave a home on Redwood Avenue near Edgewater, when the officer was wounded, Sgt. Vance Chandler said. Deputy Chief Dave Peletta said O’Sullivan was partnered with a training officer when she was shot just before 6 p.m.

2 OFF-DUTY POLICE OFFICERS IN WISCONSIN ARE KILLED WITHIN 24 HOURS

O'Sullivan lay in the backyard of a home and officers couldn't reach her because the gunman kept firing, Chandler said. Police were swarming backyards in search of a suspect and warning residents to stay inside. Multiple gunshots were reportedly heard.

The gunman likely fired from the backyard of a home there, the Sacramento Bee reported.

The paper, citing police scanner chatter, reported a suspect was pinned down and officers authorized to use lethal force.

Police said other officers maintained cover for about 40 minutes until they were able to get an armored vehicle in the area and execute a rescue of O'Sullivan. It took more than 45 minutes to get her to the hospital, Chandler said.

"To Tara's parents and family, and Tara's fellow officers, I am so sorry," wrote Darrell Steinberg on Twitter. "As a father I am grieving with you. As Mayor of the city she swore to protect, our city is heartbroken and we are here for all of you every step of the way."

Multiple law enforcement agencies were assisting the Sacramento Police Department. Police warned residents by loudspeaker to stay out of the area near the intersection of Redwood Avenue and Edgewater Road. Police were keeping media and onlookers out of sight of the scene.

CLICK HERE TO GET THE FOX NEWS APP

The suspect emerged from the front door of a barricaded home shortly before 2 a.m., ending a nearly eight-hour standoff with authorities, according to the Bee. Officers had managed to negotiate with the suspect through a cell phone, the report said.

Police said he was taken into custody. No additional details were released.