The events took place on January 6th in the southern Spanish city of El Ejido, local daily La Voz de Almería reported on Tuesday.
The 34-year-old man in question was attempting to illegally occupy an apartment in a residential building on the outskirts of the city when a group of neighbours confronted him.
Panicked by their reaction, he pulled out a gun and fired several shots to intimidate them.
But when the man attempted to put the weapon back in his pocket, he mistakenly shot himself in the pubic region.
It was the very same people he had threatened minutes before who then took him to the ER in the local Hospital de Poniente.
Sources at the health centre told La Voz de Almería the man had lost a considerable amount of blood after the bullet entered his body through the pubic region and then punctured his testicles.
Although the squatter is still recovering from his injuries, he faces charges for illegal possession of firearms as soon as he is released from hospital.