Warren Montgomery, whose outsider candidacy for district attorney of the 22nd Judicial District gained momentum just before the Nov. 4 primary, repeated that pattern in the runoff Saturday, defeating Brian Trainor with 52 percent of the vote, making him the first new district attorney in St. Tammany and Washington parishes in 30 years.

Montgomery, 59, overcame the primary front-runner, a better-funded opponent who had endorsements from the sheriffs of both parishes and a raft of other elected officials. Trainor’s money and political muscle and a well-mobilized ground game stood in contrast to Montgomery, who loaned money to his own campaign and often seemed on the defensive during the heated runoff campaign.

He captured 45,144 votes to Trainor’s 41,078.

A boisterous packed house at the Clarion Inn in Mandeville was chanting Montgomery’s name as the winner hugged supporters and took questions from reporters.

“I think people just wanted a change,’’ said Montgomery, who said he had not known how the race would turn out.

His next step will be to sit down with incumbent Walter Reed and work out a transition, including the appointment of a transition team. Montgomery said he has no plans to clean house in the office.

As for his relationship with law enforcement leaders, including the two sheriffs who endorsed his opponent, Montgomery said, “They’re professionals, and I’m a professional, and we will work together.’’

Although December runoffs typically see low turnout, the DA’s race kept interest high on the north shore, where early voting for the runoff outstripped that in the primary, despite the fact there were two fewer voting days because of the Thanksgiving holiday.

St. Tammany Parish Registrar of Voters Dwayne Wall said 17,721 voters cast ballots ahead of the election, compared with 16,506 in November.

Montgomery took an early lead Saturday night. Despite losing in Washington Parish, he maintained the lead in St. Tammany Parish and overall throughout the night, though the race got closer toward the end.

After a fairly low-key campaign in the primary, Trainor, a 41-year-old former assistant district attorney who is on leave from his position as chief deputy of the St. Tammany Parish Sheriff’s Office, came out swinging in the runoff. He blasted Montgomery as a criminal-coddling defense attorney who would have a tough time working with law enforcement officials, contrasting that to his own law enforcement bona fides.

But Montgomery, who touted his prosecutorial experience at the U.S. Attorney’s Office in the 1980s, took his own shots at Trainor, portraying him as a stooge of St. Tammany’s old guard and questioning whether he had the experience for the job.

Montgomery accused Trainor of having never acted as the lead prosecutor on a felony case, a claim denied by Trainor.

The race was wide open because of longtime incumbent Reed’s decision not to seek another term amid a federal grand jury investigation into his conduct. Once politically invincible, Reed announced in July that he would not seek a sixth term, leaving the job open for the first time in decades.

Though Reed wasn’t in the race, he still was a dominant figure in the campaign. Trainor, a former assistant under Reed from 2002 to 2010, sought repeatedly to distance himself from his old boss, saying he would have “no tolerance for corruption.” Montgomery, like the two other candidates who trailed in the primary, highlighted Trainor’s association with Reed every chance he could.

Reed never offered a formal endorsement — though some reports had him referring to Trainor as a friend during a closed-door meeting for his staff — but other officials lined up behind Trainor.

Chief among those was St. Tammany Sheriff Jack Strain, for whom Trainor has worked since 2010, most recently as chief deputy. Strain filmed a commercial for Trainor and urged his supporters to back his former lieutenant. This message formed a key component of Trainor’s overall campaign message: that he has spent his entire career either prosecuting criminals in the DA’s Office or working to arrest them as part of the Sheriff’s Office while Montgomery was defending some of them in court.

Trainor repeatedly promised that as DA, he would “keep the north shore safe,” and he directed barbs at Montgomery, who after a stint at the U.S. Attorney’s Office in the 1980s has been in private practice, including criminal defense work.

Montgomery lashed back by criticizing Trainor as overly beholden to the powerful sheriff.

Trainor also got support from Washington Parish Sheriff Randy Seal, St. Tammany Coroner Charles Preston and a number of Slidell officials.

For St. Tammany voters, corruption proved a compelling issue, as the questions swirling around Reed followed the plummet of another longtime incumbent, Coroner Peter Galvan, who pleaded guilty to stealing public funds.

Montgomery was able to capitalize on public weariness with such shenanigans, despite being the last candidate to jump into the primary.

The new district attorney will begin his six-year term Jan. 1.

He will inherit an agency in turmoil. It will be up to Montgomery to rebuild public trust in the office.

The office also has had issues with funding shortfalls, as Parish President Pat Brister pointed out when she requested an audit of the office.

Montgomery has pledged to be a full-time DA who will not maintain a private practice, something that is allowed by law.

CharacterStyle/Bullets and Numbers1

Follow Sara Pagones on Twitter at @spagonesadvocat.

Follow Faimon A. Roberts III @faimon.