Warren Montgomery, a former federal prosecutor and private attorney who ran as the anti-machine candidate, has won the race to succeed Walter Reed as 22nd Judicial District Attorney, beating Brian Trainor by 52 percent of the vote .

With 198 of 199 precincts reporting, Montgomery had 44,795 votes to Trainor’s 40,757.

Montgomery, the last candidate to enter the race after Reed announced he would not seek a sixth term, had surged into second place in the primary, and Saturday night he was true to form. He remained ahead in the totals all night long, despite Trainor’s stronger showing in Washington Parish, where he had 6,601 votes to Montgomery’s 4,819. The two Republicans fought a tough runoff race, with both camps slamming the other. But ultimately, Montgomery’s focus on cleaning up corruption resonated more strongly with scandal weary St. Tammany voters than Trainor’s emphasis on crime-fighting.

Montgomery came out strong at the start of the night, capturing the most early votes in an election that saw more people voting absentee than in the primary, despite a shortened period.

Follow Sara Pagones on Twitter at @spagonesadvocat.