Two Montana residents were injured early Monday after a handgun accidentally went off, sending a bullet through both men.

Walter M. Hofer, 35, of Great Falls, Montana, and 19-year-old Jeremy J. Kleinsasser, of Harlowton, were taken to West Park Hospital in Cody, where they were treated and released.

The Park County Sheriff's Office says someone called 911 at 7:45 a.m. Monday to report the shooting, which occurred at the Vision Quest Motel in Meeteetse.

The victims later told police they had worked together all night in the Gooseberry Oil Field outside Meeteetse. When they got to back to the motel, they began discussing guns.

Hofer took out a 9mm semi-automatic handgun and started to demonstrate how to take it a part for cleaning. As he tried to remove the slide, the gun discharged, sending a round through Hofer's left hand.

The bullet continued through Kleinsasser's right hip. The sheriff's office says both wounds were "through and through." Their supervisor took them to the hospital.

Both men were friends, and there was no history of animosity or workplace violence between them.

Park County Sheriff Scott Steward said, with the upcoming hunting season, it's a good time for people to practice and re-evaluate their knowledge of gun safety.

"Gun owners should become familiar with their weapons before handling them and always treat every weapon as if it's loaded," Steward said in a press release. "Before showing or cleaning the weapon, check it in a safe manner to ensure it is unloaded. And then check it again. Gun safety is everyone's responsibility."

More From KGAB