The shooting was reported about 4:20am and occurred in one of a row of rented rooms in Moo 10, Tambon Pak Phraek, in Muang district, Pol Lt Col Arkom Chomsri said.
Police and a doctor from Phahon Phonphayuhasena Hospital rushed to the scene and found Tarin Pinroj, 17, dead in a pool of blood on the floor of the room. He had been shot in the left cheek of his face and the bullet went through his head.
Nathapas Kumkrong, 18, told police he was playing video games in the room with Tarin. They were joined by four other boys who arrived on two motorcycles.
One of the newcomers, a 17-year-old, produced a home-made gun and was showing it to the other boys. The gun went off and Tarin was hit in the face.
The four other youths fled on their motorcycles, he said.
Muang police chief, Pol Col Puwadit Kongphet, said the parents of the youth with the gun were contacted and asked to bring their son to the police station.
The 17-year-old surrendered to police at 6:45am. He admitted to firing the shot that killed Tarin and said it was an accident. He had afterwards thrown the gun into the water under a bridge near Wat Thewasangkharam, he said.
Divers were looking for the weapon.