The California sheriff's deputy who was killed while approaching a home following a chaotic standoff that also ended with the death of the gunman, his two sons and their mother was officially identified Monday as a former Marine who served in Afghanistan and was a married father of three children. 

Kern County Sheriff's Deputy Phillip Campas, 35, was shot Sunday outside a home in Wasco, just outside Bakersfield and located 140 miles north of Los Angeles. Authorities initially responded to the home around 1 p.m. following reports of shots being fired. 

The 41-year-old suspect was the subject of a restraining order that prohibited him from possessing weapons, officials said Monday. 

As deputies arrived at the residence, they were told by a female outside that two or three shooting victims were inside and a man was inside with a gun. As deputies approached the home, the suspect began firing at them from inside, authorities said. 

They were not struck and took cover. Other law enforcement agencies, including the California Highway Patrol, responded to the scene. 

Almost two hours later, SWAT team members tried approaching the front door of the home and were fired upon. Campas and Deputy Dizander Guerrero were struck and two other SWAT members were hit by shrapnel. The SWAT officers returned fire. 

CHICAGO MOM WHO IS VISUALLY IMPAIRED MOURNS FATALLY SHOT TEEN SON WHO HELPED HER GET AROUND

Kern County Sheriff's Dep. Phillip Campas, 35, was identified as the deputy killed Sunday while responding to a home with a gunman inside.  (COURTESY: KERN COUNTY SHERIFF’S OFFICE.)

Campas and Guerrero were taken to a hospital. Campas died and Guerrero was treated and released. 

"When you talk about police officers that run toward gunfire, that's him (Campas)," Kern County Sheriff Donny Youngblood told reporters Monday.

Hours after the shooting, around 6:30 p.m., the suspect was shot by authorities as he was on the roof of the home armed with an AK-47-style rifle and handgun, the sheriff's office said. He died at the scene. 

Inside the home were three dead victims – a 42-year-old woman and two males, ages 17 and 24. Youngblood said they were the suspect's sons and their mother. Two other females and two children were also inside the home and escaped unharmed as deputies initially arrived. 

CLICK HERE TO GET THE FOX NEWS APP

Campas was a five-year veteran of the sheriff's office. He previously served in the Marine Corps. and in the sheriff's office Honor Guard and as a patrol deputy and recruit training officer. 

"We thought he had been here over 10 years," Youngblood said. "He's had that kind of impact. He was here for five."

"He probably touched this organization as much as anyone as I've ever seen in such a short period of time," he added."

Campas leaves behind a wife and three children – ages 6, 9, and 13. 

In a statement, Wasco Mayor Alex Garcia said shared his condolences over the deputy's death.  

"Nothing can prepare us for tragedies such as these," he wrote. In an instant our lives can change forever. I pray that God surrounds these families with his love and give them the strength to make it through this devastating time."

The deputies involved in the fatal shooting of the slain gunman have been placed on administrative leave pending an investigation, officials said.