SALINAS — A judge sentenced a Soledad man Wednesday to 18 years and four months in prison in Salinas for stabbing his grandparents and a responding police officer last year, Monterey County prosecutors said.

Robert Bagwell, 18, had pleaded guilty to attempted murder of a police officer and felony elder abuse causing great bodily injury in an agreement with prosecutors that kept him from three life sentences, according to the district attorney’s office.

Soledad police responded to a 911 call on May 19, 2014, from 210 Second St. in which the caller hung up. Responding Officer Thomas Marchese heard more than one loud distressed voice from inside the home when he

arrived at the front door, prosecutors said.

Marchese tried to open the door but it was locked. Marchese had his gun drawn when he forced the door open, but put it back in his holster when he saw what he thought was Bagwell punching an elderly man, according to

prosecutors.

Marchese tried to stop Bagwell, who was on top of his grandfather, and found that Bagwell was stabbing the man with a four-inch paring knife, prosecutors said.

Bagwell turned on Marchese and said, “I am going to kill you,” prosecutors said.

Marchese suffered seven or eight stab wounds to the neck and back before other officers stopped Bagwell, prosecutors said.

Deputy District Attorney Douglas Matheson said Marchese, who was wearing a Kevlar vest that prevented more severe injuries, was in intensive care after the stabbing. The grandparents were also in the hospital for weeks

recovering from their stab wounds.

Bagwell’s attorney Brian Worthington said there is little disagreement about what happened inside the home, but he said Bagwell “didn’t just decide to be violent one day.”

Worthington said his client was probably suffering from his first psychotic episode of schizophrenia, which he said prosecutors seemed to agree with.

That argument is based on the grandfather’s description of Bagwell’s behavior a few days before the attack, Worthington said.

It’s a realistic explanation of what happened, so Judge Mark Hood found him “less culpable,” Worthington said.