A Fairfax City man pleaded guilty to accidental homicide Monday in the killing of a Centreville teen last year during a marijuana deal that ended in gunfire.

Uriel Espinosa Cruz, 19, entered the plea in Fairfax County Circuit Court in the killing of 17-year-old Matthew Ortega, as part of a deal with prosecutors that called for dropping firearm and robbery charges. Under the second-degree murder charge, Espinosa Cruz could face five to 40 years in prison when he is sentenced Nov. 15.

A Washington Post deliveryman found Ortega lying on a street in a residential area in the 13000 block of Jeb Stuart Square in Centreville shortly before 5:20 a.m. Feb. 14, 2018, Fairfax County Assistant Commonwealth’s Attorney Kathleen Bilton told the judge in the case. Ortega, a Centreville High student, had suffered a gunshot wound to the head and was pronounced dead at the scene. A medicine bottle filled with marijuana was found in his pocket.

Residents in the neighborhood said they did not witness the killing, but some said they heard a shout about 10:15 p.m. the evening before Ortega was found dead, Bilton said in court.

Interviews led detectives to Espinosa Cruz.

Espinosa Cruz, then 18, told detectives that a meeting was arranged with Ortega to buy marijuana, Bilton said. Ortega, Espinosa Cruz and two other people traveled to Jeb Stuart Court to conduct the deal, but an argument ensued, Bilton said Espinosa Cruz told authorities.

Espinosa Cruz told detectives that he pulled out his gun and that it accidentally fired when Ortega put his hands up to block it, Bilton said.

The two men who were with Espinosa Cruz that night offered a differing account after they were granted immunity by prosecutors. They said the meeting with Ortega was arranged so Espinosa Cruz could rob him of marijuana.

Both people told prosecutors that they didn’t think Espinosa Cruz intended to shoot Ortega.

W. Michael Chick, an attorney for Espinosa Cruz, said his client was sorry.

“Uriel is extremely remorseful for what he did,” Chick said. “He’s sorry to Matthew’s family for the pain he caused.”

Ortega’s family, who attended the plea hearing, declined to comment.