Congress struck a deal Sunday night for a roughly $1 trillion spending bill to avert a government shutdown, a measure that appears to be largely a victory for Democrats and gives in to few conservative demands.

The House and Senate have come to an agreement on a larger omnibus spending bill which will fund the government through September. The bill doesn’t include any money for a wall on the US-Mexico border, nor does it cut federal funding for Planned Parenthood, but includes enough increases to military spending and border security funding for Republicans to claim wins.

This deal comes after weeks of marathon bipartisan negotiations on Capitol Hill, with little input from the White House. A one-week temporary funding bill passed Friday averted a government shutdown over the weekend and bought more time to iron out lasting disputes between Democrats and Republicans.

The final agreement looks to be a big win for Democrats, who have been using the threat of a filibuster in the Senate to push against President Donald Trump’s request to partially fund the border wall, increase defense spending, and gut environmental and science programs. The agreed-upon spending bill:

Increases defense spending by $12.5 billion — less than half of Trump’s $30 billion request. There is also the possibility of an additional $2.5 billion in defense, contingent on Trump presenting a plan to Congress to fight ISIS.

Does not include money for the Southern border wall or for an expanded deportation force, and leaves funding for sanctuary cities untouched. The deal will include $1.5 billion for border security for technology and to repair the existing infrastructure. Customs and Border Patrol and U.S. Immigration and Customs Enforcement will also be getting more funding for hiring border patrol agents, increasing detention beds and detention and removal programs, which Republicans see as a victory.

Does not cut funding to Planned Parenthood.

Does not include Trump’s proposed $18 billion cuts to non-defense spending. Instead, it adds $4.6 billion in new non-defense spending to make miners’ health benefits permanent, gives Puerto Rico $295 million for Medicaid, adds $2 billion for disaster relief in California, West Virginia, Louisiana, and North Carolina, and includes an additional $600 million for the opioid crisis and infrastructure.

Increases spending for National Institute of Health by $2 billion to a total of $34 billion, despite Trump’s request to cut the budget.

Cuts the EPA budget by only 1 percent, rather than the 31 percent Trump requested.

Increases clean energy and science funding by $17 million, increases the Department of Energy’s Office of Science funding by $42 million, and increases ARPA-E funding by $15 million.

An additional $131 million for Secret Service to cover the president’s protection demands

(The full text can be read here.)

In other words, it doesn’t include many of Trump’s major campaign promises — including the border wall — or the budget cuts he proposed for the upcoming fiscal year. It’s a huge blow for the Republicans, who control the House, Senate, and White House.

But Democrats had a lot of pull in the spending fight and made it clear from the outset they would not allow any “poison pill” provisions — like the border wall and defunding Planned Parenthood. They appear to have gotten their way.

How Democrats got their way

Republicans, despite controlling both houses of Congress and the White House, had a problem when it came to funding the government: They needed Democrats to sign on.

Unlike Trump’s Cabinet nominations, which only a need a simple majority of 51 votes in the Senate to pass, a spending bill needs 60 votes — meaning Republicans in the Senate need their entire party and at least eight Democrats to sign on to the omnibus.

If Republicans didn’t need Democrats to pass a bill, they could have hiked defense spending, appropriated money to start Trump’s border wall, and maybe even defunded Planned Parenthood (although Speaker Paul Ryan has said that belongs in the health care debate).

But from the beginning, Senate Minority Leader Chuck Schumer and House Minority Leader Nancy Pelosi warned Republicans that any attempt to fund the border wall, roll back environmental and consumers protections, or pull funding from Planned Parenthood would meet with unified Democratic opposition.

It appears as though Democrats got their way — and conservatives got almost nothing they wanted.

Because Republicans needed Democratic votes to fund the government, the result was a spending package that was a tough sell for conservatives. The more Republicans lost votes on the right flank, though, the more Democrats they needed to avoid a shutdown — so the spending bill kept moving ever-further left. As the chair of the Democratic Caucus, Rep. Joseph Crowley, said last week, the negotiations made it apparent that Republicans would need Democratic help to pass the bill in the House as well.

The White House took its fight from Capitol Hill to Twitter.

For a moment it looked like the White House was going play the tough guy.

When members of Congress returned to their districts in early April, the administration took a harder line on the shutdown deadline, saying funding for the wall is a “must.” Trump tweeted that Obamacare is in “serious trouble.” The president was seemingly hinting at a deal that Office of Management and Budget Director Mick Mulvaney suggested: for every dollar Republicans put toward Obamacare subsidies, Democrats could agree to a dollar for the border wall.

Then, a Democratic aide said Mulvaney told Pelosi that the White House could stop funding Obamacare’s subsidies as soon as next month, further escalating tensions over the omnibus bill. At the time, Democrats wanted to include money for the subsidies in the funding bill, which Speaker Ryan said he would not stand for.

But the White House rolled back its threat on Obamacare subsidies last week, which put Pelosi at ease. Trump himself seemed to soften the urgency of building the border wall, saying it could wait until September.

The White House’s brief attempt to strong-arm negotiations on Capitol Hill fizzled. Trump took his “fight” to Twitter, angrily tweeting at Democrats over blocking border wall funding and pushing for Medicaid payments for Puerto Rico.

Neither proved to be big enough sticking points to stop a deal.