Like other Republicans in the House Freedom Caucus, Representative Scott Perry of Pennsylvania, the group’s former leader, carries a pungently far-right portfolio.

He has been an unswerving loyalist of former President Donald J. Trump. He has bickered with his party’s elected leaders. He has voted against aid to Ukraine and against keeping the government open. He still maintains that the 2020 election was stolen. Such stances are not especially controversial to Republican primary voters.

But among archconservative House members, only Mr. Perry must sell those same views to voters in a politically competitive district this November.

The challenge confronting Mr. Perry came into sharper focus late Tuesday night, when Democratic voters in Pennsylvania’s 10th Congressional District elected as their candidate Janelle Stelson, a popular TV anchor in the area who until about a year ago was a registered Republican.

Ms. Stelson, who is running as a centrist, prevailed in a six-candidate primary that was largely upbeat and free of intraparty fisticuffs.

“I’ve had Scott Perry in my cross hairs from the moment I announced my candidacy last October,” she said in an interview.