As the bitterly fought race for Brooklyn district attorney drew to a close on Tuesday night, Kenneth P. Thompson, the Democratic nominee, claimed a sweeping victory over the longtime incumbent, Charles J. Hynes.

Mr. Hynes, 78, had already conceded the race to Mr. Thompson in September, after both ran in the Democratic primary. But a few weeks later, he announced that rather than begin the transition process, he would run on the Republican and Conservative Party ballot lines in the general election, setting up a rematch in which he accused his challenger of enabling corruption, while Mr. Thompson accused him of race-baiting and misconduct.

But Mr. Hynes’s attempt to preserve his political career — which saw him rise from junior prosecutor to candidate for governor — did not succeed in a borough where Democrats outnumber Republicans by more than 800,000. Though he had hoped his lengthy record would attract Democratic crossover votes, he was losing 27.9 percent to Mr. Thompson’s 72.1 percent with 58 percent of precincts reporting. He would be the first district attorney in the city to be unseated since 1955.

“I stand before you today, deeply grateful and truly humbled,” Mr. Thompson said at an election night party. “The people of Brooklyn,” he added, “selected a man who started out life with the deck stacked against him as a child and made that man the next district attorney of Brooklyn.”