NEW YORK — Democrats scored an upset in one of New York’s most conservative congressional districts yesterday, dealing a blow to the national Republican Party in a race that largely turned on the party’s plan to overhaul Medicare.

The results set off elation among Democrats and soul-searching among Republicans, who questioned whether they should rethink their commitment to the Medicare plan, which appears to have become a liability heading into the 2012 elections.

Two months ago, the Democrat, Kathy Hochul, was considered an all-but-certain loser in the race against Republican Jane Corwin. But Hochul seized on her Republican rival’s embrace of the proposal from Representative Paul D. Ryan, Republican of Wisconsin, to overhaul Medicare, and she never let up.

She captured 48 percent of the vote, to Corwin’s 42 percent, according to unofficial results. A Tea Party candidate, Jack Davis, had 8 percent.

Voters, who turned out in large numbers for a special election to replace the resigning Christopher Lee, said they trusted Hochul, the clerk of Erie County, to protect Medicare.

© Copyright 2011 Globe Newspaper Company.