GOP Rep. George Holding on Tuesday defeated fellow North Carolina Rep. Renee Ellmers in this year’s only primary between incumbents. 

Ellmers, competing in a redrawn district that included much of Holding's former territory, becomes the first Republican incumbent to lose this year. She had been endorsed by presumptive GOP presidential nominee Donald Trump in a final-hour effort to win.

The lawmakers were forced to compete after a federal court ordered the state legislature to redraw districts, merging Holding's and Ellmers' into one.

The final weeks of the race became a feud on the airwaves over conservative credentials, with heavy spending by the two candidates and more than $1 million from outside groups attacking Ellmers.

Holding won by a wide margin over Ellmers and Dr. Greg Brannon, a two-time Senate candidate.

The race marked Trump’s only endorsement and the first time since 2012 that two sitting members of Congress ran against each other.

Holding is expected to have a strong chance of winning the Republican-leaning district in the November general election. He'll face the winner of a five-way Democratic primary.

The race was set up by court-ordered redistricting in February that moved Ellmers' 2nd District to the north and east, absorbing much of Holding's old 13th.

After federal judges struck down two North Carolina congressional districts in February as illegally race-based, the legislature redrew the map of 13 districts and split the congressional contest off from the March presidential primary.

The Holding and Ellmers campaigns each spent more than $1 million during the election cycle, and a significant influx of money has come from outside groups attacking Ellmers or supporting Holding.

The Club for Growth, Americans for Prosperity and American Foundations Committee spent more than $1 million combined, accusing Ellmers of not being conservative on fiscal issues and failing to challenge President Obama's administration.

Ellmers, once the favorite of Tea Party activists who helped elect her in 2010, has said the outside spending is retribution for not following the groups' agendas closely enough. Holding, a former federal prosecutor, was first elected in 2012.

Outside groups -- including the pro-life/antiabortion groups the National Right to Life Committee and Susan B. Anthony List -- argue Holding, elected in 2012, is more conservative than Ellmers.

The Ellmers campaign on Saturday released a 40-second robocall from Trump declaring his support for her re-election.

“I need her help in Washington so we can work together to defeat ISIS, secure our border, and bring back jobs and frankly so many other things,” Trump said. “Renee knows how to do it. She gets it, and together we will make America great again.”

Ellmers told FoxNews.com in a statement: “I am proud to be the first member of Congress to have received an endorsement from the Republican nominee and soon-to-be president Donald Trump.”

An aide to Holding argued Trump’s backing wouldn’t change the incumbent’s record on the issues.

The Associated Press contributed to this report.