STONEHAM — Since middle school, David Atherton and Patrick Riccardi-O’Connor were best friends, and led strikingly parallel lives.
Both entered the military after high school, and spent a year deployed together in Qatar, according to Atherton’s aunt. When Atherton graduated from the Massachusetts Firefighting Academy in Stow earlier this month, his longtime friend was at the ceremony to celebrate the milestone.
On Tuesday night, the two men were playing with a handgun during a night of drinking at Atherton’s apartment when Riccardi-O’Connor fatally shot Atherton, 24, authorities said. The men were videotaping themselves as they played with the gun, authorities added.
In court Wednesday, where Riccardi-O’Connor, 23, pleaded not guilty to involuntary manslaughter, prosecutors said that Riccardi-O’Connor had used a funnel to chug beer and at one point swallowed a bullet. That, too, was recorded on video.
Riccardi-O’Connor told police he knew there was a magazine in the gun but didn’t think there was a bullet in the chamber, authorities said.
“When the police asked him about the videotape, he acknowledged that he had been fooling around with the gun, pointing it at the victim, and pulled the trigger, but did not expect that a bullet would come out,’’ said Middlesex Assistant District Attorney Adrienne Lynch.
Riccardi-O’Connor initially told investigators Atherton had shot himself, police said. Riccardi-O’Connor, in his first account to police, said he left the room to change, and when he returned Atherton was pointing the gun at his chest, asking “Do you trust me?’’
But in a later interview at the Stoneham Police Department, Riccardi-O’Connor was asked about the videotaping and told investigators that he was the shooter, officials said.
A third person was at the apartment at the time but told police he did not see the shooting.
Riccardi-O’Connor was released on $25,000 bail. His movements will be restricted and he must wear a GPS monitoring bracelet.
Riccardi-O’Connor, who works as an EMT, was licensed to carry the gun used in the shooting; his license has been revoked and his firearms have been confiscated, Lynch said. He is due back in court Aug. 3.
“This is just an unbelievably tragic situation for everybody involved,’’ said Riccardi-O’Connor’s lawyer, Andrea Levy. Some of Riccardi-O’Connor’s relatives attended his arraignment, but declined to comment.
Atherton’s aunt, Marylou Haverty, said her nephew was a handsome, lovable young man who lost both his parents when he was a teenager. His mother died when he was 13 and his father died of cancer five years later, she said.
Atherton’s brother, Richard, called her Wednesday morning to tell her what had happened, she said.
“He was never reckless. He loved his family. He loved the military. He loved being a firefighter for the short time that he was,’’ Haverty said. “We can’t understand this.’’
Atherton initially wanted to follow in the footsteps of his grandfather and namesake, David Noonan, and become a police officer, but after a few years of military service settled on becoming a firefighter, Haverty said. He worked two jobs waiting tables at restaurants in Boston before he joined the fire department, she recalled.
“Once he came home from overseas he worked so hard,’’ said Haverty, who lives in Woburn. “I think he loved the town he grew up in. I think he liked being in uniform. That’s what he wanted to do.’’
Haverty said Atherton saw some relatives Monday and told them, “I love my job. I’m so happy.’’
“This is just senseless,’’ she said. “It’s such a devastating loss.’’
Stoneham Fire Chief Matthew Grafton said Atherton was named to the fire department Feb. 11, the same day Grafton became chief. He will be buried with full military and fire department honors, Grafton said.
“We’ll give him a great send-off, the best we can,’’ Grafton said.
As a military police officer with the Massachusetts Army National Guard, Atherton was honored with the Army Commendation Medal and other awards, Grafton said.
“Firefighter Atherton always wanted to help people,’’ he said in a statement. “I cannot help but feel that the best was yet to come for this young man, and we in the Stoneham Fire Department are still coming to terms with this loss.’’
Leslie Cogan, whose daughter dated Atherton for nearly two years, said he had a close bond with Riccardi-O’Connor.
“My heart goes out to Pat,’’ she said. “He’s going to live with that for the rest of his life. They were best friends forever.’’
Scott Marino, 45, who lived across the street from Atherton on Congress Street, said Riccardi-O’Connor was always nearby.
“Those two were inseparable,’’ he said. “Wherever one was, the other one was there too.’’
Rosemarie McDonald of the Globe staff contributed to this report. Laura Crimaldi can be reached at laura.crimaldi@globe.com. Follow her on Twitter @lauracrimaldi. Reis Thebault can be reached at reis.thebault@globe.com. Follow him on Twitter at @reisthebault.