Immigration politics and Democratic infighting came together to doom the $400 billion deal even before it had made it into print. The brinksmanship threatens to disrupt the lives of millions of taxpayers who rely on the mishmash of expired provisions the plan was trying to revive.

The collapse highlights the fragile coalitions in Congress, where even leaders of opposition parties agreeing to a deal can’t bring it home. It also shows the newly found boldness of President Barack Obama in the aftermath of the midterm elections, where the looming takeover by Republicans has him tilting back toward the liberal base.

Interviews with the key players showed that the two tax-writing panels in the Senate and House had for weeks been making solid progress toward a final tax package that looked like it would include the breaks for low- and middle-income people sought by the president.

But the deal fell apart just as it seemed to be coming together. The immigration executive order soured the GOP on the tax cuts for the working poor and middle class sought by Democrats. Republicans worried undocumented immigrants targeted by the order would begin claiming the credits in droves. They found a friend in Senate Majority Leader Harry Reid, who reluctantly agreed to drop his party’s demands to extend expiring parts of the earned income tax credit (EITC) and its companion, the child tax credit.

“Everyone felt that Reid had suddenly given the store to Republicans and not gotten much in return,” said a Democratic House aide.

The president, with liberal Democratic backing on the Hill, issued the veto threat and the plan imploded, making the tax deal the first major collateral damage of the White House’s immigration action.

The internecine fight comes at the lowest point of the Obama’s relationship with Reid and the Senate’s soon-to-be disempowered Democratic leadership. White House officials — from Obama on down — have been feuding with Reid’s brash chief of staff, David Krone, and The New York Times has reported that Obama took the extraordinary step of asking Reid to exclude Krone from White House meetings.

Until late last week, Senate Finance, Ways and Means and leadership met regularly and were making progress on the package of tax breaks known as tax extenders. The group of some 55-plus tax breaks have expired, and many lawmakers in both parties want to renew by the end of the year, amid warnings from the IRS that failing to act would disrupt the upcoming tax filing season. They include everything from a major business research credit to one for teachers to be reimbursed for buying supplies.

Both sides wanted to go big and include more, throwing concerns about the budget deficit aside. Senate Finance Chairman Ron Wyden (D-Ore.) and the Democrats were entertaining the idea of more permanent business tax relief that Republican wanted, and Republicans had even offered to make the expansion of the earned income tax credit permanent, according to a senior Senate Democrat aide.

Senate Democrats had made the EITC, a wage supplement for the working poor, and the $1,000 child tax credit key priorities weeks ago. In October, Wyden huddled with Finance members to find out what concessions he should wrestle from Republicans as part of the talks. They agreed on the provisions.

But then the president announced his executive action on immigration late last week, and it all started to unravel. Republicans took the Democrats’ tax credits off the table completely.

Republicans had been railing against undocumented immigrants claiming the child tax credit for years, and the immigration order raised the prospect that they would begin claiming the EITC as well. If they agreed to extend them now, it would look like they were voting to expand government benefits to illegal immigrants.

What’s more, the EITC was notorious among Republicans for fraud. It had one of the highest rates of improper payments of any federal program. How would they sell that to rank-and-file Republicans in the House?

Some Democrats worried that the only way Republicans would ever agree to the provisions is if they included tough new rules aimed at preventing illegal immigrants from claiming them. So they dropped the idea, figuring that was better than either risking a crackdown on immigrants trying to claim the breaks or not getting a deal at all.

“It’s a political reality for Republicans,” said a source familiar with the negotiations between Reid and House Ways and Means Chairman Dave Camp (R-Mich.). “Our two biggest priorities, EITC and CTC, got taken off the table with the immigration announcement.” The source added: “If the immigration announcement had been delayed, we probably could have gotten something done.”

Democratic leadership instead emphasized other concessions they had wrung from Republicans. They got a permanent extension of the American Opportunity Tax Credit, which helps millions of middle-class voters with the cost of college. They got a permanent extension of the state and local sales tax deduction, important to many blue states. They got an extension of a break for using public transit. And they got Republicans to agree to Senate Democrats’ plans to roll over the rest of the extender provisions for another two years.

Democrats on the Hill not party to the new talks caught wind of the secret negotiations between Reid and Camp by outside sources. The rank-and-file Democrats were confused: This “came out of no where,” as one Senate Democratic aide said.

By the time The New York Times on Monday reported that the tax credits might be left out, the reality had set in that they’d been undercut.

Treasury Secretary Jack Lew quickly weighed in with an abrupt statement — warning that the administration wouldn’t accept a deal it saw as giving away too much to Republicans and their allies in the business community.

Rank-and-file Democrats on both side of the aisle were furious with Reid’s office. They, like the White House, hadn’t conceded that the tax credits were out of the question.

What’s more, the concessions Reid had won raised eyebrows among some Democrats.

“The whole reason the state and local sales tax was in there was because of Harry Reid,” said a Democratic staffer who didn’t wish to be identified.

The provision allows Americans to write off what they pay in sales tax from their federal taxes. It’s particularly important to states that have no income tax and rely on sales tax — like Nevada, Reid’s home state.

Likewise, Democrats noted that the mass transit break was particularly important to Sen. Chuck Schumer (D-N.Y.).

The White House was also furious, the Democratic aide said: “It was pretty clear that the White House feels like Reid and Schumer were trying to lock in some provision’s they care very much about … agreeing to a deal that’s overall very poor for Democrat priorities.”

Wyden’s staff set to work preparing a batch of demands for Republicans to make the deal sweeter for Democrats. And that’s when the White House swept in.

The White House had kept a distance from the negotiating table. Senate Finance Democrats were keeping the administration apprised of their talks.

By Tuesday afternoon, following more reports of the deal, White House staff contacted Wyden’s Senate Finance office to see if there was an agreement.

The staff told the White House there wasn’t — that they had never agreed to the Reid-Camp deal being reported in the media.

At the same time, Lew and Office of Management and Budget Director Shaun Donovan had begun calling Democratic lawmakers to urge them to oppose the plan.

They didn’t have to push very hard, with many agreeing it was a bad deal without the the earned income and child tax provisions.

“We should go back to the drawing board,” said Michigan Rep. Sander Levin, the top Democrat on the Ways and Means Committee. Those concerns were echoed in public by Sen. Sherrod Brown (D-Ohio), who sits on the tax-writing Finance Committee and Rep. Chris Van Hollen (D-Md.), the top Democrat on the Budget Committee.

A few hours after White House aides spoke with Senate Finance, Obama himself call Wyden to tell him he’d made a decision: He’d veto the deal.

Senate Finance Democratic tax aides spread the news to the caucus. They called a meeting at 5:15 p.m. on Tuesday, led by staff director Joshua Sheinkman, and were told: This is not a Democratic deal.

“Without saying it, he was inferring — the Reid folks were trying to cut their own deal and got too far out in far in front of things,” the aide said. “The [Democratic] committee staff were pretty pissed.”

They were also told the White House locked in enough Democratic support to sustain a veto.

The blowup brought negotiations to a standstill. Aides in both parties say they will take another run at cobbling together a deal after lawmakers’ Thanksgiving break, but neither side is optimistic.

Both sides agree the most likely outcome is the one neither want: A simple one-year status quo extension of all the breaks.