Joe Francis was nearly taken in Mexico when several men with guns busted into a home, took everyone's money ... and attempted to kidnap Joe and a group of friends.
Sources close to the "Girls Gone Wild" founder tell TMZ ... he was at the home of one of his neighbors in Punta Mita on October 16 -- with about 20 other people -- when at least 5 armed men stormed in, threatening to take hostages.
We're told Joe and the others, mostly staff working at the house, were tied up with wire and robbed. Our sources say shortly after this, neighborhood security had a scuffle with the gunmen, who fled the area ... until police spotted them.
Law enforcement sources tell us ... cops got an anonymous call that morning from another residence near Joe's, claiming 4 suspicious-looking people were spotted inside the home.
We're told 2 patrol cars with armed officers were sent to the scene and found 4 people making a run for it. Cops gave chase, but 3 of the 4 perps got away. It's unclear if the captured suspect was arrested or charged yet.
Our sources say military personnel also responded to the incident, and discarded guns and masks were discovered at nearby property. We're told the robbery victims believed the assailants planned to kidnap them.
We reached out to Francis ... so far, no word back.