WASHINGTON — President Donald Trump’s policy of separating migrant children from their families at the southern border — and his subsequent reversal — has begun affecting congressional campaigns throughout the country and complicating the efforts of many GOP candidates to find their footing on the issue.

Republicans have struggled for years with internal splits on immigration, a dynamic that played out publicly once again this week as party leaders struggled to to pass a comprehensive overhaul that could satisfy both sides.

As that drama persists, with an expected vote on a twice-delayed bill next week, it's still too early to gauge how the past week's events might affect the fall elections, but the issue is already showing up in many campaigns, especially in Senate races.

Some GOP candidates supported the initial policy of separating families, calling it necessary and “unavoidable” in enforcing the law. Now those candidates are trying to follow the president's reversal.

In Pennsylvania, for example, where Republican Rep. Lou Barletta is challenging incumbent Democratic Sen. Bob Casey, the two candidates have taken different positions.

Barletta, a longtime hard-liner on immigration, initially applauded the policy. But after Trump backtracked, Barletta followed suit. “I supported the president enforcing the laws and policies that we had and that’s what he was doing," he told NBC News. "The president changed the laws and policies, so he’s been consistent.”

Casey called it a policy “from the pit of hell,” making it clear in an interview that he “disagrees completely” with Barletta.

In Virginia, Republican Senate candidate Corey Stewart supported the policy as well. “You have to enforce the law. Otherwise you’re going to have many more people coming across the border,” Stewart said last week in an MSNBC interview.

Stewart had to revise his stance, too, after Trump did. “The president has found a way to enforce our immigration laws while keeping families together, and I applaud him for it,” Stewart said through a spokesperson.

Trump, who ran and won in large part because of his tough-on-immigration positions, is unlikely to suffer a backlash from supporters for reversing his position, said GOP strategist Rick Tyler. But his actions are hurting Republican candidates who may now have to adjust their positions.

“Trump doesn’t have supporters. He has fans,” Tyler said. “And if you’re a regular old politician, you can’t behave in that way because your political supporters will hold you to account.”

Sen. Jeff Flake, R-Ariz., echoed that concern, saying the risk for Republican candidates is that Trump is unpredictable.

“The problem is, when the president says he supports something, you don’t know how fleeting that is," Flake said. "We’ve been through this. We’ve seen this movie before. That’s frustrating and it makes it extremely difficult."

House Republicans face their own challenges on the issue when it comes to the November election. Moderate members, who are the most vulnerable and whose constituents are looking for solutions to DACA and immigration, forced leadership to take up immigration legislation. The separation of families at the border only hurts their re-election chances as it deepens the impression that Republicans are anti-immigrant.

Rep. Jeff Denham, a Republican who is facing a difficult re-election race in the farming-rich central California valley, said he is making sure that his constituents "can see that I'm addressing the issue."

GOP voters in general say immigration is the third most important issue to them, compared with fifth most for Democrats, according to an NBC/Wall Street Journal poll this month.

The current debate has played out in some familiar patterns so far. In states where the border issue isn't a constant concern, like Virginia and Pennsylvania, GOP candidates haven't strayed far from Trump, with some fully embracing the family separation policy.

In other states, it's Democrats who are finding it difficult to fully oppose the president.

In Missouri’s Senate race, Republican candidate Josh Hawley is fundraising off the issue. While he doesn’t say he supports family separation, he says his opponent, Sen. Claire McCaskill, is helping to keep the border insecure by opposing the policy.

“Secure our border, protect our citizens, allow ordered immigration to those who wish to become productive members of American society. These are common-sense principles,” Hawley wrote to supporters in his fundraising plea. “So why is Senator McCaskill fighting to allow illegal immigrants to pour across our border by using children as human shields?”

For her part, McCaskill’s reaction has been more nuanced than many of her fellow Democrats. She says she is opposed to the separation of families but tells NBC News that she supports expedited deportation.

“I’m hoping they will go back to an administrative expedited removal of people who cross the border illegally,” McCaskill said.

In North Dakota, Republican Rep. Kevin Cramer, who is challenging Democratic Sen. Heidi Heitkamp and supports similar positions to Trump on immigration and border security, said families should be kept together but there’s “nothing inhumane” about a chain-linked cage. “If it is, every ball park in America is inhumane,” he said.

Heitkamp has also said that border security is a priority, but she splits with Cramer on her tone. She said that voters are "very, very concerned for the kids."

For Republican candidates running in states close to the southern border and with large Latino populations, coming out on the side of separating families was politically risky, as evidenced by the positions Republican candidates have taken in states like Arizona, Florida, Nevada and Texas.

In Nevada, Sen. Dean Heller was an early opponent of family separation, coming out against in on Memorial Day, well before the issue escalated.

“Senator Heller doesn’t support separating children from their families, and he believes that this issue highlights just how broken our immigration system is and why Congress must act to fix it,” his spokeswoman Megan Taylor told NBC News.

While Heller separated from Trump on this issue, he's not distancing himself too much. Heller will be with the president this weekend at the Nevada Republican convention in Las Vegas.

In Florida, Republican Gov. Rick Scott, who is running for the Senate, was opposed to the policy and Sen. Ted Cruz, a Republican who is in a closer-than-expected race with Democrat Rep. Beto O’Rourke in Texas, has taken the lead in trying to legislate an end to the practice.

After coming out in favor of family separation several weeks ago — and being opposed to permanent legal status for Dreamers — Cruz quickly changed course when O’Rourke announced he was visiting a border detention center. Now, Cruz and Sen. Dianne Feinstein, D-Calif., are working on combining their respective legislative fixes to come up with a bipartisan solution.

Calling family separation "one of the real tragedies of illegal immigration," one in which "kids are often the greatest victims," Cruz said the legislation he was filing this week "would prohibit separating families, would mandate that kids stay with their families.”

In the end, geography may play a larger role than ideology when it comes to the issue of immigration on the campaign trail this fall. “It will play differently in different states,” Tyler said.