BOSTON (AP) — Longtime Massachusetts Secretary of State William Galvin has fended off a challenge from Boston City Councilor Josh Zakim in a Democratic primary race that turned caustic in its closing weeks.

Tuesday’s primary was the toughest re-election challenge for Galvin, who’s held the post for nearly a quarter-century.

READ MORE: Obama Family Announces Death Of Family Dog Bo

The contest heated up after the 34-year-old Zakim won the endorsement of activists gathered at the Massachusetts Democratic Party convention, beating the 67-year-old incumbent first elected to the office in 1994.

Zakim faulted Galvin for not moving faster to harden protections against potential hacking and other threats to upcoming elections.

READ MORE: COVID Vaccine Clinic For High School Students Opens In Westboro

Galvin defended his efforts to protect voting, saying keeping the Massachusetts voting system off the internet has reduced the possibility of an attack.

Galvin will face Republican Anthony Amore in November.

MORE NEWS: Massachusetts Reports 795 New COVID Cases, 8 Additional Deaths

(© Copyright 2018 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)