The race for 22nd Judicial District Attorney is getting narrower, with Warren Montgomery, who has led all evening, hanging on with 51 percent of the vote while Brian Trainor has risen to 49 percent in what is looking like a squeaker.

Montgomery had 35,510 votes to Trainor’s 33,915 with 159 of 199 precincts reporting.

Trainor was the top vote-getter in Washington Parish, where he captured 6,601 votes to Montgomery’s 4,819 with all 41 precincts in.

But Montgomery racked up votes in St. Tammany Parish, and the battle is going to be waved in the last 40 precincts.

Trainor, who worked for the District Attorney’s Office for eight years and who is currently on leave of absence from the St. Tammany Parish Sheriff’s Office, raised more money and racked up more official endorsements. Montgomery has run as the outsider who is best positioned to clear the cloud of corruption hanging over the office that has been under Walter Reed for 30 years.

Follow Sara Pagones on Twitter at @spagonesadvocat.