WASHINGTON — The drama surrounding passage of a massive spending bill exposed internal party tensions that had once only bedeviled Republican House Speaker John Boehner. It turns out Democrats have their divisions, too.

An increasingly liberal Democratic wing in House of Representatives showed this week it's not afraid of bucking its president. In the end, President Barack Obama peeled off enough Democrats to get his way, but the spectacle surrounding the House vote on the $1.1 trillion package demonstrated that cutting deals with Republicans has a political cost.

The break, and the last minute arm-twisting from Obama that it took to save the bill, illustrated the challenge the president faces in his remaining two years if he negotiates with a Congress that will be completely under Republican control starting next month.

"This by definition was a compromise bill," Obama said Friday. "This is what's produced when you have the divided government that the American people voted for."

Coming out of midterm elections that battered his party, Obama promptly staked out positions promoted by liberals. He moved on his own to protect millions of immigrants from deportation, negotiated a deal with China to cut polluting emissions, and unveiled a plan for a "free and open" Internet.

But the left still abandoned Obama during the spending vote, led by House Democratic leader Nancy Pelosi, one of Obama's most stalwart allies. At issue were two provisions most Democrats opposed — the rollback of the big bank regulation and another dramatically increasing limits on certain political contributions by wealthy donors.

"We don't like lobbying that is being done by the president or anybody else that would allow us to support a bill that ... would give a big gift to Wall Street," said Democratic Rep. Maxine Waters of California, referring to a provision in the bill that would roll back a regulation on big banks.

The bill now awaits action in the Senate, where it will likely pass.

In a matter of weeks, Obama has managed to zig-zag his way through Congress showing that even though weakened by the midterm losses, he retains enough influence to affect congressional outcomes. Besides pulling the spending deal out of the fire, he used a veto threat in late November to derail a tax deal Senate Democratic leader Harry Reid had negotiated with Republicans but that liberal Democrats opposed.

Annoying your own party is not unique to Obama. President Bill Clinton did it after the House shifted to Republican control in 1995 by employing a negotiating strategy known derisively among many Democrats as "triangulation."

"The president working with Republican leadership is not triangulation in the malicious sense, but it comes at a price with his own party, and I think he bumped into that yesterday," Patrick Griffin, who was Clinton's legislative director, said Friday.

In an interview Friday, Pelosi said even if Democrats don't fall in line every time to support Obama's deals with Republicans, they will be there to help Obama fight Republican measures they all oppose.

"Should the president threaten a veto, the votes will be here in the House to sustain it," she said. Veto overrides require a two-thirds majority vote in the House and Senate.

No doubt, reaching congressional compromise is difficult largely because many voters see compromise itself as capitulation. What's more moderates from both parties have largely disappeared in the House, making the Democratic caucus overwhelmingly liberal, and the GOP caucus overwhelmingly conservative. Party discipline has also weakened, making it harder for Democratic and Republican leaders to craft bipartisan measures that will survive attacks from the ideological left and right.

Still, there will be opportunities for Obama to get crosswise with a significant number of Democrats. He is eager to work with Republicans on trade deals that will likely draw stiff criticism from organized labor and environmental advocates, both key members of the Democratic Party coalition.

"It does appear that there will be a revolt on the left at least some of the time when the White House and Democratic leadership look to actually legislate alongside Republicans," said Matt Bennett, another veteran of the Clinton White House.