Tillis Ekes Out Victory in North Carolina, Bolstering Republicans’ Hold on the Senate

As Mr. Trump’s own standing with voters dropped, Mr. Tillis was in a difficult position. He toiled to appeal to independent voters who had become disillusioned with the president, but also could not risk further alienating Mr. Trump’s base. The result was a jumble that pleased no one. Mr. Tillis sponsored a bill to protect Robert S. Mueller III, the former special counsel, and initially opposed using Pentagon funds for the border wall, Mr. Trump’s signature campaign promise.

But fearing a backlash from the president’s loyal supporters, Mr. Tillis reversed himself on the wall and voted to uphold a national emergency declaration by Mr. Trump that allowed the president to siphon millions of dollars from North Carolina military installations to build the structure. Mr. Cunningham called it a betrayal of his own state.

Still, in an extraordinarily unpredictable year, Mr. Tillis benefited from some late developments that shook up the race. After the death of Justice Ruth Bader Ginsburg in mid-September, he moved swiftly to capitalize on the election-season court vacancy to reassure conservatives skeptical about his candidacy.

Mr. Tillis immediately said he would vote to confirm whomever Mr. Trump nominated, and as a member of the Judiciary Committee, he had a highly visible public stage to showcase his role in helping install Judge Amy Coney Barrett to the Supreme Court, cementing a conservative majority that Republicans have made one of their top priorities.

Another break came in early October, when it was revealed that Mr. Cunningham had carried on an extramarital affair, including during the campaign. Details were not particularly steamy by contemporary standards, but the United States Army Reserve opened an investigation because Mr. Cunningham was an officer, and The Charlotte Observer, the state’s largest paper, scrapped plans to endorse him after his evasive response.

Mr. Tillis and a cavalry of outside Republican groups spent the duration of the campaign hammering Mr. Cunningham on the airwaves for his conduct. Mr. Cunningham apologized and said he took “complete responsibility,” but he had staked his campaign on his character and his military service, making the revelations all the more damaging. His decision to hunker down and avoid questions about the scandal only fanned the flames.

“Veterans know we can’t trust Cal Cunningham,” said an unnamed veteran in one ad run by Mr. Tillis’s campaign.