President Trump and Russian leader Vladimir Putin at a joint news conference last week in Helsinki, one of several events that has complicated election campaigns for Republicans. (Pablo Martinez Monsivais/AP)

Rep. Garland “Andy” Barr has a textbook plan to win reelection in his Lexington, Ky., district — focus every day on local issues, the GOP tax cut and the specter of House Speaker Nancy Pelosi returning to power if Republicans like him lose in competitive seats.

But President Trump keeps happening, and then everything gets more complicated.

It has been a common pattern this summer for House Republican candidates around the country: Trump sparks local and national controversies around issues of trade, immigration and foreign policy that throw many of the most vulnerable House incumbents for a loop.

The latest episode in a summer of discontent for Barr and Republicans like him came last week when Trump appeared to side with Russian President Vladimir Putin’s denials of 2016 election interference, brushing aside the assertions of U.S. intelligence agencies. Barr’s spokeswoman told local reporters that he had no comment on Trump’s behavior, as he was too busy preparing for a hearing two days later.

Barr’s Democratic opponent, Amy McGrath, immediately jumped on the moment to push a central argument to moderate voters by Democratic campaigns this year: the need for a new check on Trump’s power, which she used Barr’s silence to illustrate.

“I’m outraged by the president’s actions and comments today,” she promptly proclaimed on Twitter. “When will Republicans in Congress put the country before their political party and flat out condemn these actions?”

The impact hits unevenly: While members of Congress in safely Republican districts are free to always side with Trump, those serving in more moderate districts have repeatedly found themselves squeezed between their need to court Trump supporters and the friction his actions have prompted in their districts. Their fallback is often silence.

“I was hoping and many Republicans were hoping that we would spend the whole year talking about how the president’s tax reform and regulatory agenda would take off,” said Scott Jennings, a Republican consultant in Kentucky, who remains bullish on Barr’s reelection. “Obviously, other events have interceded.”

None of this has dampened Trump’s own desire to make himself a centerpiece of the fall campaign. White House officials are trying to book two or three days a week for much of the fall for Trump to travel, in line with previous presidents. He plans to hit Illinois and Iowa next week to talk about the economy and visit a steel mill, a White House official said.

Trump is determined to make trade part of the midterm discussion — even though many in the White House are skeptical that it is a good issue, particularly in battleground Midwestern states. “It’s not like you are going to change his mind,” said one White House official, who, like others interviewed for this article, spoke on the condition of anonymity to talk candidly. “So we just have to message it the right way.”

Two senior White House officials said they receive the most complaints from Republican incumbents and candidates on trade and the president’s tariffs, as international retributions have begun to take a toll on the price of corn, soybeans and bourbon.

“At some point, the trade bubble will burst,” said a senior administration official, suggesting that if Trump doesn’t alter his course on trade Republicans will mount a more forceful pushback.

On another front, Trump’s advisers admit privately that the rollout and cleanup of Trump’s “zero-tolerance” family separation policy was botched by the administration in June, exacting unneeded political damage. But some aides, such as Trump counselor Kellyanne Conway, have argued that many of the controversies of the summer won’t resonate in the midterm elections.

The Democratic backlash to the separation policy was so extreme — including demands by some that the main domestic immigration agency, Immigration and Customs Enforcement, be abolished — that Republicans ultimately will benefit, Conway and others believe.

Another senior White House official noted that polls show Republicans still strongly back Trump, even on issues of trade and his performance with Putin. National polls also show that the share of voters saying the country is on the “right track” is about 40 percent — near the highs for Trump’s tenure.

“As long as the economy is hot, the rest of the noise won’t matter,” this official said.

But such statements do little to ease the ever-present state of anxiety for many in Trump’s own party.

“I’m always concerned. I wake up every morning and grab my phone,” said one Republican midterm consultant, who spoke on the condition of anonymity to talk frankly. “With Obama, I was able to plan weeks in advance. With Trump, I am never sure what’s coming next.”

Democratic strategists, meanwhile, have told candidates to use the revolving controversies to drive enthusiasm among liberal base voters, a tactic that has shown up in fundraising totals for their candidates. In 11 of the 17 most competitive districts where Democratic candidates have already been selected, the Democrats outraised GOP incumbents in the second quarter, according to Federal Election Commission records.

Democrats also have pushed their argument against single-party control of government, particularly to moderate voters and nervous Trump supporters.

“Even Trump voters want representatives who think for themselves, who don’t get led around by the nose,” said Geoff Garin, a Democratic pollster working on the midterm effort. “The fact that so many Republican candidates are being forced into these very tortuous noncommittal re­sponses to Trump’s excesses demonstrates to voters that they are not going to have the independence that voters want now.”

That idea has become a central theme for some of the most competitive races, and it has even filtered into Democratic messaging on the Supreme Court nomination of Judge Brett M. Kavanaugh. After initially signaling that they would oppose Kavanaugh around issues of abortion and health care, Senate leaders have lately shifted to focus on the nominee’s views on presidential power, an issue that speaks to voter fears of Trump having too much unchecked control.

Sen. Heidi Heitkamp (D-N.D.), one of the most vulnerable incumbents, struck that note in an ad. “I’m not going to be a rubber stamp for anybody,” she says in the spot, noting that she will vote for Trump’s initiatives if she agrees with them.

A TV spot by Phil Bredesen, a Senate candidate in Tennessee, takes a similar tack. After praising Trump for his meeting with North Korean leader Kim Jong Un, the Democrat pivoted to trade. “If he proposes something that is going to hurt Tennessee, I’ll oppose it,” Bredesen says, while standing in what appears to be a whiskey warehouse. “And these new tariffs will hurt us.”

Polls show that the increased tariffs are marginally unpopular nationally, and the family separation policy has been widely panned.

Some Republicans have tried to use Trump’s summer controversies to more clearly separate themselves from the president, following the Democratic approach by condemning Trump’s behavior with what one Republican strategist describes as “the full two-by-four strategy.”

Vulnerable Republican incumbents, such as Rep. Mike Coffman of Colorado, denounced Trump’s family separation strategy as “immoral,” while Rep. Will Hurd of Texas called the management of the separation “nuts” and wrote recently that Trump has “actively participated in a Russian disinformation campaign.”

“For members who have been reticent to criticize the president, it puts them in a tough position, because they have never done it before.” Coffman’s campaign manager, Tyler Sandberg, said of the president’s behavior. “With Coffman, it is not in doubt because he has been doing it consistently.”

But for most Republicans in competitive House seats, it is dangerous to directly criticize Trump.

First elected in 2012, Barr represents a district Trump won by 15 points in 2016, and internal Democratic polls show Trump still has positive job approval ratings there.

But Trump’s recent trade actions have created local pushback, from the Toyota manufacturing facility that employs 8,000 and local bourbon producers, all targeted by China, Mexico, Canada and the European Union for retaliatory tariffs.

“Our main concern is the long-term effect, because you can’t make bourbon overnight,” said Eric Gregory, the president of the Kentucky Distillers’ Association. “Once you stop filling barrels, that also affects the barrel manufacturer and the corn grower.”

Barr, whose office did not respond to requests for comment, has been forced to walk an awkward line, boasting of a recent ride on Air Force One with Trump while critiquing his actions. He set up a meeting between local whiskey makers and Vice President Pence, and he has retweeted Toyota’s complaint that the tariffs could increase the cost to produce a Camry by $1,800.

“I certainly support the administration’s objectives to promote fair and reciprocal trade,” he told Treasury Secretary Steven Mnuchin at a hearing on July 12, as he tried to navigate between his competing political pressures. “I do have concerns that tariffs and retaliatory measures on American industries could very well suppress or even reverse the record level of growth and job creation.”

His Democratic opponent, McGrath, a former Marine pilot of an F/A-18 Hornet combat jet, has tried to draw a contrast with Barr by running directly at controversies caused by Trump, casting herself as a fighter who will not behave like a cautious politician. She opposes the tariffs and family separation policies but has also been careful to call for secure borders and to oppose the abolition of U.S. Immigration and Customs Enforcement.

McGrath’s advisers say they are focused on winning over Trump supporters in the district. But rather than embrace the president’s positions, she is trying to inhabit some of his style. Her aides point to the ways she is similar to Trump, as a political amateur, a fighter and someone who will buck the system.

“Barr is not the kind of guy who wants to take a position contrary to where his party is,” said McGrath’s campaign manager, Mark Nickolas. “She is occupying a lot of the same space that Trump is occupying in representing something that is not a part of our political system.”

Republicans said they remain hopeful that Barr will hold on to the district, given the margin of victory Trump had in 2016 and his current financial advantage.

He just has to find a way to weather the storms emanating from the White House.

Late Tuesday, after Trump insisted that he had misspoken by taking Putin’s side over U.S. intelligence claims, Barr belatedly released a statement on Facebook that called Russia “a bully and enemy of the United States” and said he agreed that Russia had interfered in the 2016 election.

His only mention of Trump came in passing, in reference to sanctions that Barr supported. “I worked with my colleagues in Congress to pass a tough sanctions bill, signed by President Trump,” he wrote.

He didn’t mention that Trump had criticized the bill, at the time, as “seriously flawed” and said it contained “clearly unconstitutional provisions.”