A man and woman were apparently struggling over a pistol in a shorefront home when the gun went off, wounding him, Long Beach police allege in court documents.

In a search warrant recently filed at Long Beach Superior Court, police said the shooting happened on the night of Aug. 19 while the man and woman were in a home on Paoli Way, which runs along Marine Stadium.

The woman first told officers the gun fired while the man was playing with it, but she later said they’d been arguing, police wrote.

According to the warrant, the man got the pistol and threatened to shoot himself before pointing the gun at her. They wrestled over the weapon, and it fired, hitting the man in the arm and side, police wrote.

The man, whom police identified as 49-year-old Joseph Santomin, was not supposed to have the gun, according to the warrant.

He’d been served with a restraining order instructing him to turn over all his firearms a few weeks earlier because he’d been arrested and charged in a domestic violence incident against a different woman on June 28, police wrote.

Police suspected Santomin tried to avoid giving up his firearms by filing a false burglary report saying at least one of his guns had been stolen and then transferring ownership of the firearms to a relative, according to the warrant.

Santomin underwent surgery for his gunshot wounds and was arrested, according to authorities.

He’s now being held on $550,000 bail to face charges of possession of a controlled substance while armed, prohibited possession of a firearm, domestic violence and filing a false police report, according to court records.

He’s pleaded not guilty. An attorney who represented Santomin at his arraignment couldn’t immediately be reached.