Guardia Civil in Mijas said they were hunting the two assailants who face charges of attempted homicide.
The 50-year-old British national was discovered slumped on his doorstep with a head injury after he was smashed over the head with the butt of the gun, according to a report in Malaga's Sur newspaper.
He later told officers that he had been approached by two masked men as he reached his front door on Thursday evening at the property in La Laguna district of Mijas on the Costa del Sol.
After a scuffle one of the men pointed a pistol at the victim and pulled the trigger. It failed to fire and he pulled again, when that shot also failed the two men ran.
Reports said investigators were considering the possibility that the victim was targeted in a case of mistaken identity.