GOODYEAR, Ariz. (AP) — A man was charged with murder in the fatal shooting of a rookie Arizona state trooper still in training, state officials said.

Isaac King, 20, was charged with several counts including first-degree murder, said spokesman Raul Garcia in a statement Sunday.

The shooting occurred after troopers responded to reports late Wednesday of a person throwing rocks at vehicles on Interstate 10 roughly 15 miles (24 kilometers) west of downtown Phoenix. Motorists had also pulled over to try to get the suspect off the road, according to Arizona Department of Public Safety officials.

A fight ensued when troopers tried to get 20-year-old Isaac D. King off the roadway. Trooper Tyler Edenhofer, 24, was shot and killed during the struggle. He was in his last week of field training.

"He'd been one of my troopers for 52 days," said DPS Col. Frank Milstead.

King was transported to a hospital, but authorities would not say why he was hospitalized. He was charged after he made a remote appearance before a judge Sunday from his hospital room.

It was not clear if he has an attorney to speak on his behalf.

King, who lives in Avondale, was on medication for anxiety and depression and has no criminal record, Milstead said.

"We've talked to his parents, his mother particularly who has been cooperative and thought he was in the backyard during this event," Milstead said. "She said at about 9:30 p.m., he'd been outside on the trampoline."

Six officers, including some local police, were struggling with the suspect for several minutes when he somehow got a hold of the Trooper Sean Rodecap's weapon. Rodecap is a field training officer who was not wearing a uniform. King then fired two shots, Milstead said.

One hit Edenhofer in the shoulder but ricocheted downward, DPS spokesman Capt. Tony Mapp said. Trooper Dalin Dorris was shot through the shoulder, treated at a hospital and released.

Rodecap was injured, but not shot, in the fight.

Whether the weapon became dislodged or how King was able to fire it is under investigation, Milstead said. It was in a standard leather holster tethered to the officer's belt.

"We're all in a little bit of a state of shock," said Milstead. "The DPS family is in mourning."

Edenhofer was killed just two months after graduating from the Department of Public Safety academy. The U.S. Navy veteran was engaged to be married.

A candlelight vigil was scheduled for Monday night on the lawn of the Arizona State Capitol in Phoenix.