After Sen. John McCain (R-Ariz.) lost the presidency to Barack Obama in 2008, he spent the next four years in a colossal pout. Abandoning his previously held "maverick" positions, a newly partisan McCain helped filibuster immigration reform and campaign finance reform. He violated his own pledge to oppose filibusters of judges except in extraordinary circumstances. He refused to participate in negotiations for a bipartisan bill to avert a climate crisis, despite having recently co-sponsored such a bill with one of the negotiators. And he greeted Obama's second-term by leading the fight to prevent Susan Rice from being selected to serve as secretary of State.

But now, McCain may be the linchpin to Obama's second-term success.

This week he sealed the deal to end Republican obstruction of presidential nominees that had been hamstringing the work of the National Labor Relations Bureau (NLRB) and the Consumer Financial Protection Bureau (CFPB). Senate Majority Leader Harry Reid exulted, "John McCain is the reason we're at the point we are … No one was able to break through but for him."

Last month he played a major role in shepherding bipartisan immigration reform through the Senate, and he is keeping pressure on his Republican House colleagues by publicly warning them of political disaster if they fail to follow suit. When the initial compromise was struck, Democratic Sen. Chuck Schumer singled out McCain: "His wisdom, his strength, his courage, his steadfastness and many other adjectives that I'll skip at the moment, have really been inspiring to me and, I think, to all of us."

Less successfully, he supported the bipartisan deal to expand background checks for gun purchases. His support wasn't enough to overcome a filibuster, but the chance remains for another legislative push before the end of the term.

Beyond dealmaking, McCain has been rhetorically lashing out at right-wing libertarian members of his party for failing to be constructive, both when refusing to allow formal budget negotiations to occur and when attacking the president's counterterrorism policies.

Even when McCain is antagonizing Obama, he's helping. McCain ramped up the fight to filibuster Defense Secretary nominee Chuck Hagel, then called it off. He accused Obama of a "cover-up" in the Benghazi matter, then refused to back impeachment. He puffs up right-wing outrage bubbles, then pops them.

But the deals are where McCain may prove to be Obama's biggest second-term ally. By ending Republican obstruction of NLRB appointments, the agency can put behind the constitutional questions around the president's earlier recess appointments that had left recent NLRB decisions in legal limbo, frustrating both workers and employers. And a fully functioning NLRB gives Obama a renewed opportunity to strengthen worker rights that have been degrading for decades.

By ending Republican obstruction of Obama's choice to run the CFPB, Republicans abandoned their last ditch effort to nullify this cornerstone of Obama's financial reform law, allowing Obama to lock down new bank regulations that could prevent future market meltdowns.

And if immigration reform does eventually clear the House and reach the president's desk, McCain will have facilitated what may become Obama's biggest second-term legislative victory, ending the underground economy of second-class citizens.

Why exactly McCain has shifted his posture in Obama's second-term we may never know, but it's certainly rational. To remain bitter until the end of his Senate career would have rendered McCain as little more than a sad footnote in history. But to shake off his 2008 defeat and work with the president on issues he's long cared about gives McCain the chance to be one of the most consequential senators (and defeated presidential nominees) in history.

And if McCain really wanted to seal his place in history, he might think about restarting those climate talks.