The near-defeat of the microstamping bill yesterday may very well signal the end of the long – and lucrative- relationship between Mayor Bloomberg and the Senate Republicans in a crucial election year when the minority can ill-afford to lose the billionaire mayor’s financial support.

“I would say the relationship suffered a major setback,” said a source intimately involved in the debate.

“The mayor cares very much about guns. If the Republicans couldn’t give him three votes on a microstamping bill, what does that mean if they take back the majority? They’ll never put a gun bill on the floor.”

Bloomberg, who made a special trip to the Capitol (a place he is widely known to dislike immensely) to lobby in favor of the measure, had a heated exchange during a closed-door meeting with Sen. Tom Libous, a Binghamton Republican, in advance of the vote that saw the measure abruptly yanked from the floor before it went down in flames.

Sources with knowledge of the meeting confirmed the “passionate” debate between Libous, the deputy Senate minority leader, and the mayor, during which voices were raised on both sides.

The debate was on the substance of the bill, which was vehemently opposed by the gun lobby. But the subtext of the argument was almost certainly political.

Libous privately argued to members of his conference that Bloomberg, who has contributed $1.2 million to the Senate GOP since 2003, is unlikely to continue his support given the close split in the chamber and should therefore not be put ahead of the gun lobby, which not only has deep pockets, but also passionate grassroots advocates in crucial upstate districts.

Bloomberg’s last check for $500,000 to the Senate GOP’s housekeeping committee came in February 2008, just as the battle for control of the chamber was shaping up. The mayor bet wrong in that contest, as the Democrats ended up winning the majority for the first time in more than four decades.

The mayor hasn’t written a single check to the GOP since, but the damage he did by backing the losing side was deep. Bloomberg is very unpopular among a certain segment of the Democratic conference, most notably with key African American lawmakers.

But Bloomberg’s relationship with the Senate Democrats might be improving. It hasn’t been lost on his administration that Democratic Conference Leader John Sampson has delivered for the mayor on two of the three big issues the mayor cared deeply about: School governance (although that came amid the coup and was very messy) and charter schools.

Sampson also tried his best on microstamping, but could not get upstaters like Bill Stachowski, Darrel Aubertine and Dave Valesky to budge, which is why the mayor needed three GOP votes.

He looked for them from the NYC Republicans – Frank Padavan, Marty Golden and Andy Lanza. But of those three, only one – Padavan, a long-time Bloomberg ally – voted “yes.” Lanza voted “no” and Golden received a well-timed phone call that took him out of the chamber while the roll was being called.

Bloomberg’s team was particularly nuclear with Golden, who, according to sources, told the mayor at the tail end of a budget meeting in Albany last week that he would likely get what he needed on the microstamping bill.

The mayor went out of his way to praise both Padavan and Sampson in his statement following the microstamping vote yesterday. He made no mention of Golden.

Golden insisted yesterday that he was not to blame for the bill’s demise, noting even if he had voted “yes” it would not have been sufficient to counter the three Democratic “no” votes.

Meanwhile, observers are still scratching their heads over why Libous chose to go toe-to-toe with the GOP’s biggest benefactor. One theory is that he wanted to box in Senate Minority Leader Dean Skelos, whose job Libous has long been speculated to covet.