President Donald Trump elicited the typical internet guffaws Wednesday after he sent a tweet insulting Paul Ryan’s intelligence, telling the House speaker he should refrain from “giving his opinions” about birthright citizenship, a proposal he “knows nothing about.”

On one level, it’s true that there’s a comedic irony to this — the idea that Ryan is not up to speed on immigration, but Trump is. But on another level, the tweet reveals some useful insights into the state of Republican politics.

Generally, presidents and party leaders stand unified in the final days of the election, but not Trump and Ryan.

Ryan threw cold water on the president’s proposal to end birthright citizenship through executive order: “You obviously cannot do that,” Ryan told a local Kentucky radio station, saying the right to citizenship to those born in the United States was guaranteed through the Constitution — and therefore would need congressional action.

Trump lashed out at this assessment: “Our new Republican Majority will work on this, Closing the Immigration Loopholes and Securing our Border,” Trump tweeted, subtly dissing Ryan, who is retiring this year.

Paul Ryan should be focusing on holding the Majority rather than giving his opinions on Birthright Citizenship, something he knows nothing about! Our new Republican Majority will work on this, Closing the Immigration Loopholes and Securing our Border! — Donald J. Trump (@realDonaldTrump) October 31, 2018

The back-and-forth is one example of a larger tension inside the Republican Party that’s played out many times between Ryan and Trump.

When Ryan took over as speaker of the House, he was expected to unify the Republican party behind Obamacare repeal, tax cuts, and dismantling the welfare state. Republicans did pass a huge tax cut bill, but Ryan has spent most of the last two years placating a president who has no interest in his agenda, and who in many cases — like on immigration, trade, and changes to entitlement programs like Social Security — breaks with the Ryan wing altogether.

Ryan has largely stood by the president once he took office and Trump reminded him Wednesday that he couldn’t care less.

Paul Ryan defended Trump to the bitter end. Trump supporters couldn’t care less.

Ryan has made apparent efforts to align with Trump. During the 2016 campaign season he would disavow Trump’s racist remarks, but he tempered his condemnations once Trump took office. When Trump reportedly called a number of African nations “shitholes,” Ryan said it was an “unfortunate” and “unhelpful” comment. As for Trump’s apparent attempts to gain influence over FBI Director James Comey, Ryan said Trump was “just new at this.” He’s even given the president credit where credit was not due on health care and tax reform policy.

When Ryan announced he is on his way out, he made it clear that he’d defend Trump until the bitter end. Asked if Trump’s reshaping of the Republican Party played a role in his decision to retire, Ryan said, “Not at all.”

But Trump’s supporters inside and outside Congress aren’t as willing to return the support. In September 2017, reports cropped up of conservative efforts to oust Ryan. Axios reported that conservative lawmaker, and Trump confidante Rep. Mark Meadows (R-NC) had met with former White House adviser and then-Breitbart executive Steve Bannon to float alternatives for Republican leadership. The Washington Post said the Freedom Caucus was “privately plotting” ways to force Ryan to adopt their hardline agenda.

Ryan has his reasons to stick with the president; in theory, by keeping Trump at bay, he would be able to push through the Republican Party’s ambitious agenda. But Trump brought a very different reality.

Instead, after months of highly visible party infighting, Obamacare repeal failed epically. Republicans deeply underestimated the time they’d spend excusing Trump’s tweets and White House scandals. They managed to pass tax cuts, but the law doesn’t appear popular enough to help them win elections. Meanwhile, Trump is stuck on the one policy issue that will only deepen party divides: immigration.

Trump forces Ryan into an impossible problem — then blames him for it

If you ask those in Ryan’s inner circle, it becomes clear that immigration was never one of the speaker’s top priorities.

It’s in large part because Trump and Ryan likely don’t see eye-to-eye on the issue. Ryan’s views are often said to have been shaped by his mentor Jack Kemp — the pro-immigration New York Republican whom Ryan worked for early in his career and with whom he remained close until Kemp’s death in 2009. Trump has repeatedly espoused the views of anti-immigration hardliners.

As a compromise, Ryan made it clear that his role on immigration is to facilitate rather than advance policy. He allowed votes on two very conservative immigration proposals — one backed by immigration hardliners, and one seen as more of a Republican consensus bill. Both failed.

If you ask conservatives, Ryan has had too light a touch. They say it’s because of Ryan and Senate leadership that a Republican majority has repeatedly pushed through spending bills without any conservative immigration policy priorities, from defunding sanctuary cities, to funding the border wall.

Conservatives have been more than willing to throw Ryan under the bus. And Trump is on their side.

So now Trump says he will work with a “new Republican majority” to push forward his agenda. Perhaps he means Majority Leader Kevin McCarthy, the California Republican who Trump fondly refers to as “my Kevin.” McCarthy seems ideologically closer to the president and has made it clear that he intends to run for speaker if Republicans keep the majority.

But that’s a big if. The election is less than a week away, Democrats are in a good position to take back control, and Trump is lashing out at his own party’s leaders.