A 17-year-old Loudoun youth admitted in court yesterday that he fatally shot his 15-year-old friend and former classmate this spring, a slaying that prosecutors said occurred as the youths were "posing and posturing" with a stolen Glock semiautomatic handgun.

Matthew J. Lathram pleaded guilty in Loudoun County Circuit Court to involuntary manslaughter in the March 22 slaying of Donald Nicholas Shomaker. The teenager, who was charged as an adult, also entered guilty pleas to six drug and weapons charges, including possession of cocaine and possession of a sawed-off shotgun. Lathram faces a maximum punishment of 95 years in prison.

Documents filed in court yesterday, which provide the most detailed account thus far of the events leading up to the shooting, indicate that the teenagers spent the afternoon driving around with friends and smoking marijuana. At one point, Lathram tucked the unloaded pistol under his shirt when the group stopped at the house of a youth they had "beat up" a week earlier, the documents state.

Later that evening, in the basement of his Ashburn home, Lathram again put the pistol under his shirt and was "mimicking" the visit to that youth's house when he fired the shot that killed Shomaker, the records state.

Lori O'Meara, the victim's mother, clutched one of her son's tiny blue and white baby sweaters and wept during the brief hearing. She and Shomaker's father, Kevin Shomaker, declined to comment afterward.

But Donald O'Meara, the victim's grandfather, said he was upset that prosecutors agreed to an involuntary manslaughter conviction. O'Meara said the family had been told by sheriff's investigators that teenagers who knew Lathram had signed sworn affidavits stating that Lathram had threatened Shomaker.

"It didn't have to be a plea bargain," O'Meara said. "Let him go to trial, and if he gets off so be it."

Loudoun Commonwealth's Attorney James E. Plowman said that he met with Shomaker's parents and that they did not object to the plea deal. He said Lathram did make some remarks to friends, but detectives concluded they were "bravado," not serious threats. In the end, investigators concluded that the shooting was not intentional.

"The bottom line is that the kid is pleading to seven felonies," Plowman said. "I'm satisfied, after we did a thorough investigation and turned over every stone, that his exposure to almost 100 years in prison is a satisfactory result."

Prosecutors said in court documents that the day of the shooting Shomaker, a freshman at Broad Run High School, got off the school bus and invited a friend to his Ashburn townhouse, where the two smoked marijuana and played video games. Lathram, who had attended Broad Run but was enrolled in an alternative program, and another teenager called Shomaker on the telephone and the four youths went out, driving a car.

At one point, Lathram took the handgun from the car trunk and removed the clip, the documents state. The Glock had been stolen two days earlier from an Ashburn home and Lathram had bought it from two friends.

Eventually the teenagers ended up in the basement of the Ashburn house that Lathram shared with his grandparents. They smoked marijuana and "were looking at, handling, cocking and 'dry firing' the gun," the documents state.

One of the teenagers went home when Lathram left to have dinner, but Shomaker and another youth stayed, according to the records. At some point, the clip was placed back in the pistol. Lathram finished his dinner, and the teenagers again began to play with the weapon. This time Lathram shot Shomaker.

Prosecutors said Lathram initially denied the shooting but quickly admitted that he pulled the trigger and said it was accidental.

According to the documents, Lathram told a sheriff's deputy he didn't know Shomaker was hit until his friend said, "You [expletive] shot me; now I'm gonna die."

After the shooting, Lathram tossed the Glock in the bushes and put another pistol and a sawed-off shotgun in his grandmother's car, the documents state. Investigators later found $1,680 in cash in his bedroom and also seized cocaine, psychedelic mushrooms and marijuana from the house.

Prosecutors said yesterday that Lathram is cooperating with authorities and could provide information that will lead to more arrests. Last month, a 16-year-old was charged with stealing the Glock and other weapons and is awaiting trial.

Lathram's attorney, Alex Levay, said his client remains distraught and that Lathram and Shomaker were "the best of friends." Lathram's sentencing is scheduled for Dec. 2.

"The last thing in the world that Matt wanted to see happen was to see his friend shot," Levay said.