Associated Press Videos Democrat Joe Cunningham, a moderate ocean engineer, won in South Carolina's Republican-held 1st Congressional District thanks to his opposition to offshore drilling.

Opposition to offshore oil drilling powered the Democratic takeover of South Carolina’s 1st Congressional District, one of the most surprising Election Day wins for the party as it wrestles with its stance toward the industry most culpable for climate change.

Democrat Joe Cunningham, a moderate ocean engineer and resolute opponent of President Donald Trump’s plan to open the East Coast to offshore drilling, defeated Republican Katie Arrington, who initially spoke positively about the policy change.

Arrington had defeated Rep. Mark Sanford (R), who opposed offshore exploration, in a June Republican primary. Arrington argued that Sanford, a staunch fiscal conservative who publicly criticized Trump, was insufficiently supportive of the president.

In the end, however, Trump’s policies and Arrington’s initial support for them cost Republicans a once-safe district that includes Charleston, Beaufort and other coastal communities.

“You can’t go to D.C. and represent these communities fairly if you support offshore drilling,” said Nancy Mace, a Charleston-area Republican state representative and offshore drilling opponent who won re-election handily on Tuesday and did not endorse in South Carolina’s 1st. “That was certainly an issue that crept up, and I think was above-the-fold No. 1 of any other issue in that particular race.”

“That was the issue. It was the focal point of the whole campaign,” said Ben Mack, the head of the Sierra Club’s South Carolina chapter.

Trav Robertson, chairman of the South Carolina Democratic Party, called opposition to offshore drilling “central” to his party’s good fortune in the district.

“It was an issue that transcended political party, demographic, age,” he said.

It may continue to do so. The fossil fuel industry spent more than $100 million this election to defeat key ballot measures in Arizona, Colorado and Washington. Yet oil and gas companies failed to make the same inroads on the East Coast, where Florida voters overwhelmingly approved a ban on drilling in state waters on Tuesday. The White House is planning a major pipeline push in the next year, teeing up a new wave of fights over polluting infrastructure.

The Trump administration announced plans in January to expand offshore oil and gas exploration rights in the Atlantic, Pacific and Arctic oceans, overturning restrictions on the practice put in place by the Obama administration.

Then, in a May debate with Sanford, Arrington said she supported Trump’s actions.

“When we talk about offshore drilling ― nothing’s happening,” she said. “It’s President Trump ― and I support what he did ― he lifted the ban on offshore drilling.”

Charleston’s this beautiful historic city. We don’t need that kind of debris lying about. Jimmy Carroll, mayor of Isle of Palms

Tyler Jones, a spokesman for Cunningham’s campaign, told HuffPost that finding those comments, which were not widely publicized when she said them, was “the most pivotal moment in the campaign.”

Arrington struggled to backtrack on the remark, voicing opposition to offshore development on her website, in TV ads, in direct mail and on social media, according to Andrew Boucher, a spokesman for her campaign.

“She came out against offshore drilling in South Carolina about 47,000 times,” Boucher said in an email. “I’m not sure what more she could have done to make it clear.”

South Carolina’s 1st is a highly educated, affluent district in the Low Country region that is heavily dependent on coastal tourism. The country club-style Republicanism of the district was already somewhat at odds with Trump’s coarse style and penchant for immigrant bashing. And an influx of professionals from more liberal parts of the country had also been diluting the district’s reddish hue.

As a result, Trump won in the 1st there by just 13 percentage points in 2016, significantly underperforming Sanford’s 22-point re-election margin.

Arrington’s support for opening the coast to offshore drilling was an additional blow for some onetime GOP partisans. Days after her primary win, the mayors of the coastal towns of Folly Beach and Isle of Palms, both of whom are Republicans, cited the specter of offshore drilling in their endorsement of Cunningham.

Offshore drilling “was everything,” said Isle of Palms Mayor Jimmy Carroll, whose only non-Republican vote in 2016 was for Libertarian presidential contender Gary Johnson.

Carroll cited both the environmental and economic impact of a potential oil spill in the tourism-heavy region, as well as the more immediate aesthetic damage of the onshore equipment needed to conduct the exploration and drilling.

“Charleston’s this beautiful historic city. We don’t need that kind of debris lying about,” Carroll said.

Folly Beach Mayor Tim Goodwin, who voted for Trump and Sanford in 2016, had a similar assessment. He was particularly peeved that Trump had exempted Florida, where the president owns resorts.

The proponents of offshore oil and gas exploration often tried to assure Goodwin that because there was no oil and gas to be found off of South Carolina’s coast, he had nothing to worry about.

That did not persuade Goodwin, the mayor told HuffPost. “If we can all agree there’s no oil out there, why do we wanna mess up the environment?”

Both Carroll and Goodwin said that they would have enthusiastically backed Sanford if he had remained the Republican nominee.

Associated Press Republican Katie Arrington defeated Rep. Mark Sanford (R-S.C.) in a June primary only to lose to Cunningham in the general election.

The high-profile Republican support Cunningham received for his stance allowed him to cast himself as a moderate, independent-leaning Democrat with crossover appeal.

He hammered Arrington for her May remarks in his advertisements, including a 30-second October spot featuring a wetsuit-clad Cunningham treading water in the ocean with his face to the camera.

“I have always opposed offshore drilling. My opponent ― not so much,” Cunningham says in the ad. The camera then cuts to the clip of Arrington.

Carroll, Goodwin and other Republican elected officials from coastal towns touted their support for Cunningham in the candidate’s final advertisement.

Meanwhile, Arrington began denying that she supported offshore drilling and argued that she would be in a better position to lobby the Trump administration to protect South Carolina.

In late September, Arrington posted a photo of herself talking to Vice President Mike Pence on Facebook.

“Thankful to have a few minutes this morning with Vice President Mike Pence discussing our #SC1 Lowcountry and sharing my strong opposition of drilling for oil off of South Carolina’s coast,” Arrington wrote alongside the photo.

Arrington financed an ad in early October exclusively devoted to claiming that she was the more effective opponent of offshore drilling. It was a theme she would return to in her final ad, in which she repeated her opposition to offshore drilling, yet also lamented that it was “all [Cunningham] talks about,” when there were many important issues facing the district.

But it was only one of many messages Arrington tried against Cunningham. She also blanketed the airwaves with more cookie-cutter national themes, painting Cunningham as a “Nancy Pelosi liberal” who would be soft on immigration enforcement.

But some of Arrington’s skeptics didn’t buy her about-face.

“You’re gonna come out in the middle of the campaign and switch sides ― that doesn’t do a whole lot for me,” Goodwin said.

At the same time, Cunningham got a boost from 314 Action, a PAC that supports scientist candidates. 314 Action spent over $520,000 on ads touting Cunningham’s environmental record and slamming Arrington for her May comments. One spot even noted that Arrington’s campaign had received contributions from the oil and gas industry after backing Trump’s decision to lift the ban on drilling.

Jamie Henn, a co-founder of the grassroots environmental nonprofit 350.org, said Cunningham’s win could be a model for other Democrats.

“This could be a potent issue for Democrats going forward, but only if they clearly maintain their opposition to the fossil fuel industry,” he said. “Combined with Florida’s offshore drilling ban, you’re seeing a green wall of opposition to drilling along the entire Eastern Seaboard.”