OAKLAND — An 18-year-old man was arrested Wednesday after the pistol he was playing with at his East Oakland home went off, fatally wounding his 17-year-old friend from Sacramento who was sleeping at the time, police said Thursday.

Even though police believe the shooting was accidental, the man was arrested on suspicion of murder pending a review of the case by the Alameda County District Attorney’s office. His name was not released pending the review.

Luis Urquidez, who police said had spent the night Tuesday at the home in the 800 block of East 18th Street where his friend lived, was sleeping when the suspect woke up and began “playing around” with a semi-automatic pistol, police said. The gun went off at 7:14 a.m., striking the victim. He was taken to a hospital where he died at 11:40 a.m. Wednesday. There were a half-dozen people at the home at the time, but no one else was hurt.

Police said the witnesses were scared and initially gave conflicting accounts to investigators about what happened. Someone also removed the gun from the house. After extensive questioning, police determined what led to the shooting and who was responsible. The 18-year-old later admitted his involvement and the gun was also recovered, police said.