NASHVILLE, Tenn. — Nashville Mayor Megan Barry revealed Wednesday that she had an extramarital affair with the former head of her security detail, apologizing and indicating she plans to continue serving in office.

In a news release, the mayor said she accepts full responsibility for the pain she caused her family and the family of Sgt. Robert Forrest, her former security chief. She apologized to her husband, Bruce, who she said remains committed to their marriage.

And she apologized to the people of Nashville, adding that she remains firmly committed to working hard to serve them. The popular mayor, who was elected in 2015, said progress has been made to offer affordable housing, improve public education and promote better transportation options, but there’s more work to be done.

“God will forgive me, but the people of Nashville don’t have to,” Barry said in the news release. “In the weeks and months to come, I will work hard to earn your forgiveness and earn back your trust.”

The first-term mayor’s admission follows the painful loss of the Barrys’ only son, Max, in July after an overdose on a combination of several drugs, including two opioids.

She planned to address the media Wednesday night.

“I knew my actions could cause damage to my office and the ones I loved, but I did it anyway,” Barry said. “I must hold myself to the highest standard of which the voters deserve to expect. Please know that I’m disappointed in myself but also understand that I’m a human and that I made a mistake.”

Forrest said on Jan. 17 he would retire Wednesday after 31-plus years with Metro Nashville Police. He spent 14 years of that tenure supervising the mayor’s security detail over three administrations.

In a news release Wednesday, Forrest said he never violated his oath as a police officer or engaged in actions that would abuse the public trust. The retired officer asked for privacy as he seeks to rebuild the trust of those he loves the most.

“I deeply regret that my professional relationship with Mayor Barry turned into a personal one,” Forrest said in the release. “This has caused great pain for my wife, my family, friends and colleagues.”