District Attorney Jay Gaither said Wednesday that lingering frustration over his prosecution in the Zahra Baker case played a role in his defeat Tuesday.

A three-term Republican from Catawba County, Gaither lost to Morganton attorney David Learner in a hotly contested runoff.

“There is no doubt that was a major negative for me, and I regret that tremendously,” Gaither said. “Because the prosecution of Elisa Baker is regarded nationally as a textbook prosecution.”

Gaither, who oversees cases in Catawba, Caldwell and Burke counties, drew national attention during the case of Zahra Baker, a 10-year-old Hickory girl found murdered and dismembered in 2010.

In a controversial agreement with prosecutors the next year, her stepmother, Elisa Baker, pleaded guilty to second-degree murder and was sentenced to 18 years in prison. Critics said Baker deserved a stiffer sentence.

In the campaign, Learner called that an example of Gaither’s “soft” plea bargains. He agreed it played a role in the runoff.

“People are very, very frustrated with the lenient plea bargains that have gone on,” he said Wednesday. “They’ve become very aware of that with the handling of the Zahra Baker case.”

After getting less than a third of the vote in May, Gaither said he wasn’t surprised when he lost Tuesday’s runoff. He began telling his family days ago that he expected to lose.

“I think the results of the first primary are indicative of the lack of confidence the public had in me at the time,” Gaither said Wednesday. “It’s not enough that you do a good job ... You’re expected to be the conscience of the community.”

Referring to some past cases, Gaither said, “There were several errors in judgment that affected people’s opinion of my ability to use good judgment.”

The campaign was clouded in its final weeks by a lawsuit by a former assistant prosecutor who claimed sexual harassment by Gaither. The suit says Whitney Nicole Shaffer resigned after the workplace became intolerable.

Gaither has said the allegations aren’t true. He said the claims were politically motivated.

The suit became part of a campaign marked by accusations. Gaither, for example, called Learner “a confidence man” who used his credibility as a lawyer to recruit people to a multilevel marketing company that the Federal Trade Commission called a pyramid scheme.

Wednesday both candidates put aside their differences.

“The way he brought the fight to the campaign shows me he has the fire in the belly to serve the people of North Carolina,” Gaither said.

Learner said “as far as all the negative stuff that has been said, I have just forgiven that with all my heart.”

Learner, 57, is unopposed in November. Gaither will remain in office until after that. He said he promised Learner “the most seamless and cooperative transition that we could ever put together.”