House Majority Leader Kevin McCarthy really, really wants to be speaker. There’s just one thing standing in his way: Trump’s agenda.

A fractured Republican Party (and a rumored affair) ruined McCarthy’s speakership chances in 2015. Now everything appears to be falling in place for the California Republican to be named the next leader of House Republicans. Speaker Paul Ryan is leaving Congress at the end of this year. McCarthy has positioned himself as the heir apparent — seemingly gaining the support of both Ryan and Majority Whip Rep. Steve Scalise, the other possible contender for the post — and he’s one of President Donald Trump’s closest allies on Capitol Hill.

But there’s one factor he can’t control: For him to become speaker, Republicans need to keep their House majority this November, and there are already indications that Democrats are energized enough to take back control.

To be sure, the road to a Democratic-run House won’t be easy; they’d have to flip 24 seats from red to blue in November. A third of those seats are in McCarthy’s home state of California, where seven of the 14 Republican lawmakers represent districts Hillary Clinton won in 2016. And a year of Republican policies that have hit blue states the hardest has given California Democrats a lot of campaign ammunition.

The so-called blue wave is unlikely to touch McCarthy personally. His district, encompassing Bakersfield, is one of California’s most conservative regions, and McCarthy’s fundraising prowess, affable demeanor, and ability to keep his California Republican colleagues in lockstep with the party has carried him far with his constituents and in the national GOP.

But while McCarthy’s alliance with Trump has served him well in Washington, in California, that could be his biggest liability. And it has the potential to thwart his dreams of the speakership once again.

McCarthy is a Trump party man

McCarthy, the No. 2 House Republican, is an established name in Washington.

He’s held a seat in the House since 2007. Before that, he served as the minority leader of the California State Assembly — a position he was elected to as a freshman state lawmaker. In 2015, he made clear his ambitions for the speakership, running to replace the embattled retiring John Boehner. But his campaign was short-lived; rumors of an affair with a colleague and an archconservative revolt from the House Freedom Caucus pushed McCarthy to step behind Paul Ryan instead.

In the following three years, the factors that once deemed McCarthy’s leadership dreams untenable have largely washed away. He’s both close to Ryan in leadership and a friend of Trump’s, who reportedly calls him “my Kevin,” an alliance that will make it harder (although not impossible) for Trump-loving House conservatives to break ranks with him.

Unlike Ryan, McCarthy is not someone known to lead a policy debate, but on Capitol Hill, he’s well-liked and persuasive — enough to give vulnerable Republican members assurances of electoral protection as long as they vote with the party. At his best, McCarthy is a “skilled political tactician,” said Kurt Bardella, a former Breitbart consultant and former spokesperson for Rep. Darrell Issa (R-CA). “Kevin is a political animal.” He’s kept California Republicans in line with the party more consistently than Republicans from other blue states like New York or New Jersey.

“I think he certainly understands ‘vote conscience’; vote your district, and then vote party,” Bardella said. But McCarthy manages to translate “vote your conscience” and “vote your district” into “vote party” — an understanding that winning a Republican primary requires being with Trump, even in California.

But for most Republicans in the state, it’s a shortsighted strategy — and one that’s already pushed two vulnerable Republicans in swing districts, Issa and Rep. Ed Royce, to retire. “For Republicans in California, we have seen over the past decade a strong shift to the right; members play what will be best in a primary, not what will play in a general,” Bardella, who now identifies as a Democrat, said. McCarthy might be able to align with Trump and still withstand a general election in his deep-red district, but others are not as politically flexible.

When confronted with this, McCarthy appears unfazed by the prospects of a Democratic takeover in the general elections this November.

“You know, when I look at retirement, I look at retirements for the Republicans who retired in seats that Hillary Clinton carried and Democrats who retired in seats that Donald Trump carried — you know what that number is? Five to four,” McCarthy said in an interview with GOP strategist Frank Luntz at a Milken Institute event this week. “We’ll pick up two seats in Minnesota.”

California is crucial territory for Democrats in 2018

However you look at it, Democrats’ path to a House majority in 2018 involves California. There are 14 Republican-held districts in California, and Democrats are targeting 10 of them. A fast-growing minority population (overall, California’s Latino population is larger than its white population) have made what were once Republican strongholds in the Los Angeles suburbs in Orange County, the Central Valley, outside Sacramento, and outside San Diego all potential ground for Democratic victories. There are seven districts currently held by Republicans in California that Trump lost in 2016.

The Democratic Congressional Campaign Committee — the official arm for Democratic House races — has already run a generic drive-time radio ad in a Central Valley media market, which encompasses two targeted Republican-held districts, on health care. Alongside immigration and the GOP tax law, Republicans’ Obamacare repeal efforts will be among Democrats’ biggest messaging points.

When Republicans pushed through their tax bill through the House and Senate, Minority Leader Nancy Pelosi made her message to California Republicans clear:

“After their deafening silence, any California Republican who votes for the GOP tax scam will be forced to answer why they care so little for their constituents,” she said in a statement.

It’s the same message Democrats gave when House Republicans voted for the American Health Care Act — the House’s repeal of Obamacare — and when Trump announced he would be ending the Deferred Action for Childhood Arrivals program, which protects 223,000 young undocumented Californians from deportation.

Meanwhile, Trump has made it clear he has no intention of making any overtures to the state. In April, he tweeted disparagingly about Democratic Gov. Jerry Brown, who has taken a decisive stand against Trump’s immigration agenda.

Governor Jerry Brown announced he will deploy “up to 400 National Guard Troops” to do nothing. The crime rate in California is high enough, and the Federal Government will not be paying for Governor Brown’s charade. We need border security and action, not words! — Donald J. Trump (@realDonaldTrump) April 19, 2018

The president’s approval rating sits at around 30 percent statewide. According to a March poll by the independent Public Policy Institute of California, Brown’s approval rating has held around 54 percent, despite state-federal tensions over immigration.

But that hasn’t stopped Republicans from aligning with Trump. California has a culture of partisanship that’s unlike that of other states. Democrats control every statewide office and have supermajorities in both the chambers of the state legislature. A 2014 study from the American Political Science Association showed California has by far the most polarized state legislature in the country. It’s a dynamic that’s pushed the state’s Republican base far to the right, though the general electorate is still strongly anti-Trump — 78 percent of California Republicans view Trump favorably.

Trump’s agenda is Kevin McCarthy’s agenda. It’s bad for California Republicans.

Three policy fights — health care, tax reform, and immigration — have defined Trump’s first year in office. McCarthy has championed all of them and kept his Republican Californian colleagues in line, often putting their electoral prospects at risk.

All 14 California Republicans voted in favor of the House’s Obamacare repeal bill, a proposal that would have cut $880 billion from Medicaid, a program that covers 13.4 million Californians in the nation’s largest Medicaid program. To put that in context, 50 percent of Republican Rep. David Valadao’s constituents rely on the program, in a Central Valley district that is centered in the San Joaquin Valley and more than 70 percent Hispanic.

All but two — Issa and Rep. Dana Rohrabacher (R-CA) — voted for the GOP tax law. The law caps the income and property state and local deduction at $10,000 and lowers the mortgage interest deduction for newly issued loans from $1 million to $750,000. In places like Rep. Mimi Walters’s affluent suburban Orange County district surrounding Irvine, for example, 46 percent of residents take the state and local tax deduction, according to the Tax Policy Center. The median home price in her district is $685,800. Only 36 percent of likely California voters approve of the Republican tax law, whereas 58 percent disapprove.

The dangers for sticking with Trump’s agenda is perhaps most visible on immigration, an issue on which Trump has pulled the Republican Party far to the right and that has seen substantial pushback from California’s state government.

As CNN’s Ronald Brownstein reported in April, some Republicans strategists have made the political calculation that sticking with Trump on the issue will “minimize losses” in California:

”It’s a winner for Republicans to fight this battle because as of now the conversation is framed as a public safety issue,” says GOP consultant John Thomas, who works with Shawn Nelson, the Republican Orange County Supervisor who led the effort to ally the county with Trump’s lawsuit. “In areas like Orange County where registration is starting to tilt against Republicans, those independent swing voters ... lean Republican on law and order issues.”

But moving to the right on immigration in California is a risky political move. Growing minority populations in historically white regions like Orange County have substantially narrowed Republican advantages in traditionally more conservative districts. In the Central Valley, deportations and the fear of deportation have threatened local economies. According to the PPCI poll, 55 percent of California’s likely voters support policy to protect the legal rights of undocumented immigrants.

“Immigration is their Achilles’ heel; it’s why [Republicans] will never be able to win elections,” Bardella said. “It is a measurable trajectory on how the demographics have changed in California. Particularly on immigration ... it confounds me how unwilling they are to change their politics.”

Two California Republicans stand away from the pack. Valadao and Rep. Jeff Denham, who represent largely Hispanic districts in the Central Valley, where deportations are highly visible, hold more moderate positions on immigration. But neither has done much to actually push policy, which Democrats see as an act of deference to Republican leadership.

As for the others, they’re joining Trump’s fight against California’s so-called sanctuary city laws. Rohrabacher even offered to foot the legal bill for the city of Fountain Valley to file a court brief supporting the federal lawsuit against the state’s immigration policies.

Did McCarthy talk himself out of a speakership?

McCarthy says he thinks Republicans will stay in control of the House in 2018, and he’s clearly been able to convince his fellow California Republicans that sticking with the party’s agenda is a winning strategy.

California Republicans have acted more like Republicans in the rest of the country than expected in a blue state.

“California Republicans seemed to be more inclined to take votes that really damaged their reelection prospects,” one Democratic campaign aide said. “Whether that is because of Kevin McCarthy or these folks aren’t used to having to run competitive races, I don’t know. ... They are doing very little to stand apart from the Washington agenda, which is toxic.”

Already, Democrats have seen surprise victories in 2017 and 2018, winning down-ballot races in deeply red districts in Virginia, Ohio, and Wisconsin and claiming a surprising upset win in a Pennsylvania special election in a Trump district. The generic ballot hovers around a 7 percentage point lead for Democrats — which might be enough to constitute a wave election. In California, where not only are demographics shifting away from Republicans but the GOP agenda has adversely affected constituents, some have already written off Republicans’ prospects.

“The next speaker might be from California, but it’s not going to be Kevin McCarthy,” Bardella said.

In California, which sends the third most Republicans to the House, this wave could have a major impact on the political makeup of Congress. For McCarthy, it could make or break his dreams of the speakership.