Nashville Mayor Megan Barry: I had an affair with my former head of security Megan Barry admitted that she cheated on her husband Bruce.

 -- Nashville Mayor Megan Barry on Wednesday admitted to having an affair with the former head of her security detail.

The man in question, retired Sgt. Robert Forrest of the Metro Nashville Police Department, subsequently admitted to having the affair with Barry.

"Today, I have acknowledged publicly that I have engaged in an extramarital affair with the former head of my security detail," Barry said in a prepared statement. "I accept full responsibility for the pain I have caused my family and his. I am so sorry to my husband Bruce, who has stood by me in my darkest moments and remains committed to our marriage, just as I am committed to repairing the damage I have done."

Forrest, a 32-year veteran of the police force, retired on Wednesday just hours before Barry released the statement, according to WKRN.

"I have had an outstanding career and have enjoyed coming to work each day," Forrest said in his resignation letter to Capt. Michael Alexander.

Forrest made no reference to the affair in his resignation letter but he later issued a statement through his lawyer, in which he confirmed the affair with Barry.

"I deeply regret that my professional relationship with Mayor Barry turned into a personal one," Forrest said in the statement. "This has caused great pain for my wife, my family, friends and colleagues. At no time did I ever violate my oath as a police office or engage in actions that would abuse the public trust."

Barry and her husband's only child, 22-year-old Max Barry, died in July of an apparent drug overdose. Forrest was the one to inform Barry of her son's death, according to ABC affiliate WKRN.

At a press conference Wednesday night, Barry revealed that the consensual relationship with Forrest began several months after she took office. Though she didn't say exactly how and when things ended, Barry said the affair stopped after conversations between their spouses and the realization that their relationship would become public.

"It's over," Barry repeated to reporters. "It ended with saying, 'It's over.'"

"It was clear that our personal lives were going to become public and we had made a serious mistake and we needed to step up and we needed to own it, and that's what I'm doing today," she added. "I'm here today to admit I have personal failings. I am only human, and I didn't stop being human when I became the mayor."

According to documents released by the mayor's office and obtained by WKRN, over $30,000 have been spent on Barry and Forrest's travel expenses since January 2017. The documents show Barry took a total of 30 trips during that time, nine of which were with Forrest alone.

Information from the Metro Nashville Police Department, also obtained by WKRN, shows Forrest's overtime pay has doubled since Barry took office.

During Wednesday night's press conference, Barry said "every single" trip was business-related and that Forrest's overtime pay matches her "aggressive schedule."

"When I came into office I set a very aggressive schedule because I wanted to be out in the community, be with people and be at events," the mayor told reporters. "I think you will see that lines right up with the overtime because we were out busy working."

She added, "There were no policies that were violated, nothing illegal happened. The records will absolutely show that the expenses match with the overtime expected. But I welcome anybody to take a look at that."

Barry, who was elected Nashville's mayor in 2015 and is the first woman to hold that post, apologized to the people of Nashville for her actions and said she remains "firmly committed" to serving them as mayor.

"I knew my actions could cause damage to my office and the ones I loved, but I did it anyway. 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," she said in her prepared statement. “While I regret any distractions that will be caused by my actions, I remain firmly committed to working hard to serve the people of Nashville now and into the future."

Barry added, "In the weeks and months to come, I will work hard to earn your forgiveness and earn back your trust."

ABC News' Kevin Kraus contributed to this report.