Democrats scored an upset in one of New York’s most conservative Congressional districts on Tuesday, 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 party’s 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 the Republican, Jane Corwin. But Ms. Hochul seized on the Republican’s embrace of the proposal from Representative Paul D. Ryan of Wisconsin, to overhaul Medicare, and she never let up.

On Tuesday, she captured 47 percent of the vote to Ms. Corwin’s 43 percent, according to unofficial results. A Tea Party candidate, Jack Davis, had 9 percent.