(John Ferrarone/AP)

Rep. Edward J. Markey (D) won the Massachusetts Senate race Tuesday, defeating Republican Gabriel Gomez with the help of ample reinforcements from national Democrats looking to avoid a repeat of Republican Scott Brown’s 2010 upset victory.

With nearly all precincts reporting Tuesday night, Markey led Gomez 55 percent to 45 percent, according to the Associated Press, which called the race about an hour after polls closed. Markey’s special election win will keep 54 senators in the Democratic Caucus, compared to 46 in the GOP Conference. The longtime congressman and dean of the state’s U.S. House delegation will fill the seat once held by Secretary of State John F. Kerry.

The win comes nearly three and a half years after Democrats hit bottom in deep blue Massachusetts. Republican Scott Brown defied the odds in early 2010 to snatch a seat from Democratic hands when he defeated Attorney General Martha Coakley (D) in a special election to fill the Senate seat once held by the late Edward M. Kennedy.