SACRAMENTO (CBS SF) — A sheriff’s deputy was killed in a shootout with a suspect from the Bay Area at a Sacramento motel Wednesday that also left two California Highway Patrol officers injured, according to authorities.

Sacramento County Sheriff Scott Jones identified the deputy as Robert French, a 21-year-veteran of the department. Jones said French died on the way to the hospital after being shot.

The CHP officers who were shot were both in stable condition and expected to survive, Jones said.

Two police chases followed the the shootings. In one of them, the shooting suspect crashed and was then shot by officers during an exchange of gunfire, according to authorities.

The sequence of events began outside a Ramada Inn on the 2600 block of Auburn Boulevard. A sheriff’s auto theft task force was staking out the motel Wednesday morning and observed people entering a stolen vehicle, sheriff’s spokesman Sgt. Tony Turnbull said.

The car led the officers on a chase to Elk Grove at around 10:30 a.m. where two female suspects were arrested, said Turnbull.

When other officers went to investigate the room at the Ramada Inn where the women had been staying, a male suspect opened fire from inside the room through the walls and front door, hitting the two CHP investigators, said Turnbull.

Other officers responded and encountered the suspect with a high-powered rifle on the balcony at the rear of the motel room as he tried to make an escape, said Turnbull.

“The suspect went to the back balcony of the room [and] exited with a high-powered rifle with a large capacity magazine and began to engage with our deputies in the back,” explained Turnbull.

After an exchange of gunfire in which the sheriff’s deputy was hit, the suspect got into a vehicle and led officers on another pursuit on local streets before the vehicle crashed.

There was another exchange of gunfire after the crash and the suspect was hit and taken into custody.

Authorities later announced that the suspect was a 31-year-old man from the Bay Area, but did not identify him. The suspect was in a Sacramento hospital in critical condition with multiple gunshot wounds from the final chase and shootout prior to being apprehended.

The gun used by the man held a high-capacity magazine, which are now illegal to purchase in California, authorities said.

Jeff Marshall, who lives near the hotel, said he heard gunshots and then tires squealing and saw a gray Dodge Charger speed by his home, going the wrong way down a busy street.

Marshall estimated he heard 12 shots.

“It was like the wild West,” Marshall said.

Sheriff Jones described French, 52, as a well-known, well-respected training officer assigned to patrol the county’s northern areas.

A shelter-in-place order was in effect at the Ramada Inn and the area around it for a number of hours following the shooting as authorities investigated the scene.

Sheriff’s Special Enforcement Detail and Sacramento Police Department’s SWAT team established perimeter on the motel. They isolated the room where the shooting took place, not knowing whether there were additional suspects inside the room.

After several hours, the tactical teams entered the motel room and deemed it safe. The scene was handed over to Homicide detectives.

Investigators did say the suspect taken into custody after the pursuit was the man who fired off the balcony and is believed to have fatally shot Deputy French.