The naked girl who allegedly broke into Bam Margera's house and masturbated on his bedroom floor didn't just appear out of nowhere -- she had secretly been LIVING in Bam's tree house for weeks ... the "Jackass" star tells TMZ.
As we first reported, cops arrested the 24-year-old woman Friday in the area surrounding Bam's Pennsylvania mansion ... and according Bam, the girl told police she had been living on his property for weeks leading up to her wild bedroom invasion.
Bam tells us ... the girl had been camping out in the giant tree fort on his property -- the same fort featured as Fast Eddie's Treetop Casino in an episode of "Viva La Bam."
After she was arrested on charges of burglary, criminal trespass, and stalking, Bam says cops found evidence the girl had been living in the tree house -- including clothes and garbage.
But she didn't just hole herself up in the treetops -- Bam says the girl had knocked on his parents' door a couple of weeks ago with luggage, claiming she had moved from Florida to marry her son. Bam says his mother sent the woman away ... after trying to set her up with a homeless shelter.
As for the woman, we're told she's still in custody -- being held on $50k bail.