Something weird has been happening in Washington — President Donald Trump has been palling around with Democrats.

Last week, Trump struck a deal with Chuck Schumer and Nancy Pelosi to keep the government funded and raise the debt ceiling.

This week, he met the pair again over Chinese food to discuss protecting DREAMers from deportation — and while there’s no final deal yet, they all agreed on the overall structure of one.

In addition to dealings with the leaders he now calls “Chuck and Nancy,” Trump seems increasingly set on winning Democratic votes for his tax reform bill, even though GOP leaders want a partisan strategy.

And in a presidency that’s so often been joyless and combative, Trump now seems to be having fun — reports claim he was “jovial” at this week’s meeting with Democrats, and that he just seems to enjoy spending time with his fellow New Yorker Schumer.

“He likes us. He likes me, anyway,” Schumer was overheard saying on a Senate hot mic Thursday.

Trump has several motivations here. He seems to want to improve his image (he’s reportedly been thrilled at positive media coverage of his bipartisan dealings). He’s personally disappointed and frustrated with Republican leaders Paul Ryan and Mitch McConnell’s strategic advice and lack of legislative success so far.

But perhaps most importantly, it has finally sunk in to Trump that under the Senate’s current rules, he needs 60 votes to get bills through — and since there are only 52 Republican senators, that means he needs Democrats.

Democrats, for their part, have realized that Trump cares more about getting “wins” than about policy details or ideology — which seems to give them a major advantage in negotiations with him. So if Trump’s main goal is to get to yes, they can conceivably score major policy concessions from him.

So though partisan incentives are sure to doom this relationship as the 2018 midterms approach, for now Democrats are trying to get what they can from a president they see as a bit of a sucker — and Republicans aren’t yet sure how to stop them.

Trump’s legislative agenda has stalled so far

President Trump continues to implement a hardline conservative agenda in his appointments and his executive actions. He’s cracking down on unauthorized immigrants, he’s sabotaging Obamacare, he’s rolling back environmental regulations, and he’s naming staunch conservatives to the courts.

But when it comes to his legislative agenda, he’s rethinking his approach.

Shortly after his unexpected victory last November, Trump signed on to an ambitious and partisan legislative strategy crafted by Speaker Paul Ryan and Majority Leader Mitch McConnell. Using a special Senate process, they planned to circumvent the Senate filibuster for both of their top legislative priorities: the repeal and replacement of Obamacare, and reform of the nation’s tax code. Doing so, they could pass both major bills with zero Democratic votes.

Nearly eight months after Trump’s inauguration, that strategy has yet to bear fruit. On health care, uniting 50 of 52 Senate Republicans around one plan proved too difficult, and the effort failed dramatically in July. Furthermore, the decision to put Obamacare repeal first has delayed the tax reform process, which itself has an uncertain road ahead.

All this has damaged Trump’s relationship with Republican leaders — over the summer, Trump and McConnell publicly sniped at each other, and Trump is said to blame Ryan for what seems like a disastrous decision to tackle Obamacare repeal first.

Trump has realized he can’t get to 60 Senate votes without Democrats

But as Trump has stewed over his lack of legislative accomplishments so far, he seems to have realized the real reason his Republican majorities have failed to get anything big done: the Senate’s filibuster rule.

Under the chamber’s rules, 60 votes are effectively necessary to advance almost any bill. A simple majority is not enough. And the 52 Senate seats the GOP controls puts them a long way off from 60.

So if that is the cold reality, what is Trump to do about it?

At first, he signed on to Ryan and McConnell’s “budget reconciliation or bust” strategy for his two major legislative initiatives. But there are a host of Senate rules restrictions that make that process difficult to use. Furthermore, cutting out Democrats made the effort bitterly partisan and ended up sinking the health bill.

Second, Trump tried to make the case that the Senate should just change its filibuster rule. It is technically possible for a simple majority to ram through a rules change, after all. So Trump argued that this is what Republicans should do:

If Republican Senate doesn't get rid of the Filibuster Rule & go to a simple majority, which the Dems would do, they are just wasting time! — Donald J. Trump (@realDonaldTrump) August 23, 2017

If Senate Republicans don't get rid of the Filibuster Rule and go to a 51% majority, few bills will be passed. 8 Dems control the Senate! — Donald J. Trump (@realDonaldTrump) August 25, 2017

These pleas, however, fell on deaf ears. Republicans viewed the filibuster as a crucial tool when they were in the minority during the Obama years, and there’s little enthusiasm for changing it.

So if budget reconciliation has failed, and Senate Republicans won’t change their rules, then what is a president in search of legislative accomplishments to do other than reach out to the Democrats who control the crucial votes?

Republicans, sorry, but I've been hearing about Repeal & Replace for 7 years, didn't happen! Even worse, the Senate Filibuster Rule will.... — Donald J. Trump (@realDonaldTrump) September 8, 2017

...never allow the Republicans to pass even great legislation. 8 Dems control - will rarely get 60 (vs. 51) votes. It is a Repub Death Wish! — Donald J. Trump (@realDonaldTrump) September 8, 2017

Democrats are playing ball because they think they can win real concessions from Trump

So that explains why Trump is reaching out to Democrats — but there’s still the question of why Schumer and Pelosi are willing to deal with a president who’s so loathed by their base.

The answer, basically, is that they think they have the opportunity to get really good deals from him. And they think that’s the case for a few reasons.

First, Trump cares little about policy details or ideology. His main goal in these negotiations is a big-picture “win.” And he’s proven to be willing to give up a lot in pursuit of that. For example, he could have driven a hard bargain by demanding serious wall funding be included in any deal to protect the DREAMers. Instead, he’s done the opposite, preemptively agreeing that that deal won’t include the wall.

Second, Trump’s relationships with the Republican leaders who do know and care a lot about policy details are currently quite bad. So rather than negotiating as a team with Ryan and McConnell, Trump is talking with Schumer and Pelosi while his own party’s leaders aren’t even in the room. Democrats naturally see this as an opportunity to split the Republicans and win concessions they might not be able to if they were facing a united front.

Third, Trump remains extremely popular with Republican voters — far more popular than Ryan and McConnell. If he agrees to a deal and pushes hard for them to pass it, they’re going to have a difficult time doing otherwise. So if Trump agrees to a deal that Democrats think is favorable, they have a good shot at getting it through.

Even if these dealings don’t end in sweeping new laws, they could provide benefits for Democrats. For instance, if Trump decides he needs Democratic votes on tax reform and is willing to engage in protracted negotiations and make major concessions to get there, the process could bog down and ensure a quick Republican-only bill won’t pass.

Politico’s Rachael Bade and Burgess Everett recently reported that this is just what Republicans fear — they think their best chance of success is by moving to pass a partisan tax bill through budget reconciliation, but Trump seems increasingly enamored of bipartisanship.

This flirtation is probably doomed

The deals or burgeoning deals we’ve seen so far are, first, one that perpetuates the government funding status quo, and second, one that (if passed) would protect DREAMers in exchange for some to-be-determined border security stuff. These have been deals Democrats have been happy to make (though the border security details remain to be hammered out).

But if Trump and Republicans start taking a harder line in negotiations — demanding deals that entail true sacrifices or painful concessions from Democrats — the party will likely refuse to go along.

After all, as ideologically malleable as Trump can be occasionally, he remains utterly loathed by the Democratic base — and for very real reasons, since much of his government is implementing a hardline conservative agenda. Deals where Democrats actually give anything up would be a tough sell to the base.

Furthermore, Democrats’ prospects in the midterms are closely linked to Trump’s popularity. If the president is perceived as successfully working with Democrats to get things done, there naturally seems to be less of an imperative to put Democrats in charge of Congress, after all.

So don’t expect this to last too long. But for now, Democrats are trying to get the concessions they can, while Trump is trying to get some accomplishments.