Representative Nancy Mace, Republican of South Carolina, on Tuesday defeated a well-funded primary challenger, putting her on track to win a third term. Her resounding victory also dealt a major blow to former Speaker Kevin McCarthy’s efforts to exact political retribution against those who voted to oust him.

Ms. Mace, 46, who once leaned center on social issues, won a Democratic seat in 2020 and claimed that all of former President Donald J. Trump’s accomplishments had been “wiped out” by his behavior on Jan. 6, 2021. But she has made a hard tack to the right over the past year as she has tried to game out her political future.

She was the unlikeliest of the eight rebel Republicans who voted to oust Mr. McCarthy last year, which transformed her from an ally into one of his top targets for revenge. Outside groups with ties to Mr. McCarthy, a California Republican, poured more than $4 million into backing her opponent, Catherine Templeton, and attacking Ms. Mace.

In the end, though, Ms. Mace won comfortably: With nearly all the vote in late Tuesday, she was leading by 27 percentage points. And she said Mr. McCarthy’s effort motivated her to work harder.

“I hope to embarrass him tonight,” she said earlier Tuesday over lunch at a Waffle House in Beaufort, between stops at polling locations. “I want to send him back to the rock he’s living under right now. He’s not part of America. He doesn’t know what hard-working Americans go through every single day. I hope I drive Kevin McCarthy crazy.”

A spokesman for Mr. McCarthy declined to comment, and Ms. Mace did not mention his name in her victory speech on Tuesday night.