The Republican Party faces a tough fight to keep its congressional majorities with midterm elections just over three weeks away. Candidates are distancing themselves from President Trump as cost-of-living issues dominate voter concerns. Despite this, the party holds a financial edge, with Elon Musk donating over $276 million since July.

The Republican Party's hopes of saving its majorities in Congress increasingly appear to depend on a few possible outcomes: G.O.P. advantages in money and on the map pay off, the polls are wrong, or a major news development suddenly brightens the party's prospects.

In the meantime, Republicans in competitive races are doing whatever they can to try to loosen their ties to President Trump's agenda, which is dragging their party down with just over three weeks to go before the midterm elections.

There have been new ads stating opposition to Trump's tariffs from candidates who supported them, calls to end the war in Iran from candidates who backed it and efforts to look bipartisan from candidates who pledged to be Trump's top allies.

The debates last week made clear that Republicans are on the back foot. Questions about high prices, tariffs and the war dominated the sessions in battleground states. While G.O.P. advertising often aims to link Democrats to their party's left-wing figures and stoke disputes about transgender athletes, cost-of-living issues are paramount to voters this year.

Trump's rhetoric is not helping his party. Even as his own approval ratings have plummeted, he urges voters to pretend that he is on the ballot. He touts data centers that are even less popular than he is. And he has shown no inclination to back off from his positions on the war in Iran or tariffs.

But then there is the money.

Thanks to Trump's super PACs and well-heeled political allies, Republicans still hold a commanding financial advantage. The billionaire Elon Musk has directed more than $276 million to Republicans since the start of July.