A left-leaning challenger takes down a moderate Democratic congressman in Oregon.

Representative Kurt Schrader of Oregon, a seven-term Democrat, lost his primary battle to Jamie McLeod-Skinner, a striking defeat of a leading moderate in Congress and a potential sign of left-leaning energy less than six months before the midterm elections.

Mr. Schrader, who had been endorsed by President Biden and had the backing of the national party, was toppled by Ms. McLeod-Skinner, a small-business owner and emergency response coordinator who ran unsuccessfully for Congress in 2018. Her victory was declared by The Associated Press on Friday.

Some national Democrats believed that Mr. Schrader, the well-funded chair of the centrist Blue Dog Coalition’s political arm, was the better general election choice in what is expected to be a difficult political environment for their party, given his moderate instincts.

But Ms. McLeod-Skinner’s supporters argued that she stood a better chance of galvanizing Democratic voters, a vital strength in a year in which many party strategists believe Republicans are more enthusiastic than Democrats about turning out.

Ms. McLeod-Skinner had the backing of some left-leaning organizations including the Working Families Party, and her primary victory in spite of a funding disadvantage will be seen as evidence of progressive energy after several notable setbacks for that wing of the party in 2021 and a mixed record this year.

But rather than running an ardently left-wing campaign herself, she sought to cast Mr. Schrader as a deeply conservative Democrat who was out of touch with others in his party on matters like social spending and who was too close to pharmaceutical interests.

She also amassed considerable support from local institutions, including several county Democratic Party organizations in Oregon that would ordinarily be expected to back the incumbent or remain neutral. Leaders of some of those parties had urged the House Democratic campaign arm, which supported Mr. Schrader, to stay out of the primary.

Johanna Warshaw, a spokeswoman for the Democratic Congressional Campaign Committee, noted that the organization’s “core mission is to re-elect Democratic members.”

Mr. Schrader, who was helped by significant outside spending, argued that he had a long track record of delivering for the district. A founder of the bipartisan Problem Solvers Caucus, he emphasized his ability to build consensus and his focus on issues including infrastructure, jobs and lowering health care costs.

“He has been a partner to the Biden administration,” Deb Barnes, Mr. Schrader’s spokeswoman, said in a statement ahead of Election Day.

While the race took on national significance given Mr. Schrader’s seniority, it was also shaped by hyperlocal issues, including a debate over the proper method for how to buck hay, reflecting the rural parts of a district that includes most of Oregon’s central coast.