New Jersey Democrat Bob Menendez is projected to hang on to his U.S. Senate seat after a bitter re-election campaign that followed a mistrial in a corruption case, according to an NBC News projection.

The result will come as a relief to the Democratic Party, which could not afford to lose a Senate seat from what is usually a solid blue state.

Democrats were already at risk of losing ground in the Senate, where the party was defending 10 seats in states that President Donald Trump won in 2016. The GOP held a 51-49 advantage in the chamber heading into Election Day.

Menendez's Republican rival in the race, former pharmaceutical executive Bob Hugin, used a mostly self-funded campaign to hammer the Democrat for months. Hugin unleashed a torrent of ads targeting Menendez for his ethics issues.