An 18-year-old Pennsylvania teen has been convicted of murdering his 16-year-old friend, and the incident came to light because the shooter posted a selfie with the dying boy via Snapchat.

Maxwell Morton faces up to 40 years in prison after being convicted of third-degree murder by a Westmoreland County jury last Thursday. Morton testified on his own behalf and said he did not intentionally kill Ryan Mangan in February 2015. Instead, Morton said, the boys were playing with what he thought was an unloaded handgun that he pointed at Mangan and fired.

During the four-day trial, Morton testified that he took the selfie to memorialize what happened to his "best friend." "Something in my head told me to take a picture of what happened," said Morton, who was 16 at the time of the murder. The selfie, taken with a mobile phone, shows Morton smiling in front of Mangan's body slumped in a chair. Defense attorneys unsuccessfully tried to exclude the picture from trial, but jurors were eventually shown the image. They spent six hours deliberating, and ultimately the jury did not believe the first-degree-murder allegations that the defendant had intentionally shot Mangan in the face.

"I pulled the trigger and the gun went off," Morton testified.

Local media reported that a pathologist had testified that the boy would have survived "with appropriate medical care" because he did not immediately die. Morton's attorney later told media his client contemplated suicide after.

Morton implicated himself the evening of the murder while playing video games online with a Wisconsin teenager, according to testimony. The Wisconsin teen testified that Morton bragged that he "got his first body." The gamer didn't believe Morton, who then texted a story about the shooting and sent the selfie via Snapchat. A follow-up text said, "Told you," according to the Wisconsin boy's testimony.

The Wisconsin gamer said he took a screenshot of the selfie and told his mother, who then alerted the authorities.

Morton is expected to be sentenced in May.

Listing image by Leonieke Aalders