Tom Brady and Gisele Bundchen’s armed bodyguards opened fire on paparazzi at the couple’s nuptials in Costa Rica, blasting out the windows of a pho tographer’s SUV, and just missing the shaken lensmen, the fotogs said yesterday.

Just moments after they talked their way out of an argument with Brady’s irate buddies and hired goons, a bullet smashed through the rear window of the SUV and then through the front windshield, just missing the heads of the two fleeing photo journalists on Saturday night, they said.

“Thank God I’m all right. At that moment, I thought I was going to die,” lensman Rolando Aviles told The Post.

“The bullet went between us, missing our heads,” Aviles said. “If the bullet been a little more to the left or right, it would have killed one of us.

“I said, ‘They’re going to kill us,’ and that’s when I hunched down to cover myself.”

Aviles said he and colleague Yuri Cortez, both veteran photographers hired by the INF photo agency, had permission from Gisele’s neighbor in Santa Teresa to shoot the wedding ceremony from a vista about 300 feet away from the ceremony.

Brady and Gisele were married in Los Angeles County in February, and were renewing their vows on Saturday. Just as the photographers started snapping, the couple’s bodyguards spotted them and chased them, according to Aviles.

The pair ran back to Cortez’s Suzuki SUV, parked about 500 feet away in dense brush.

They split up as they ran away, and by the time Aviles said he reached the SUV, his colleague was already there speaking to a Brady bodyguard.

Aviles quoted the guard as saying, “Tom Brady just wants to talk to you. It’s OK, nothing’s going to happen.

But when the photographers accepted the guard’s invitation back to Gisele’s house, they were swarmed by three members of the wedding party and five hired goons dressed all in black.

The New England Patriot quarterback’s best man berated the photographers and wanted to provoke a brawl, the lensmen said.