Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Nashville Mayor Megan Barry resigned Tuesday after pleading guilty to stealing thousands of dollars from the city while carrying on an extramarital affair with her bodyguard.

The rising Democratic star had been an extremely popular mayor with an ambitious agenda to transform the city into a major urban center when she stunned residents earlier this year by admitting to the affair. Her downfall was swift and she will be replaced Tuesday by the city's vice mayor.

"While my time today as your mayor concludes, my unwavering love and sincere affection for this wonderful city and its great people will never come to an end," she said at a news conference shortly after she appeared before a judge.

In court, Barry didn't say how she stole money from the city, but an investigation found that she was engaged in her relationship with her bodyguard while on city-paid trips. Authorities also found a nude photo and partially nude photo of a woman that were taken by the phone of her bodyguard, Sgt. Robert Forrest, while was on duty.

The Tennessee Bureau of Investigation did not identify the woman in the photos and Barry has said that if the photos are of her, they were taken without her knowledge or permission.

The nude and partially nude photos were shot last May and October, on days that Barry's travel schedule shows she was on separate Washington trips.

Former Nashville Mayor Megan Barry's mug shot. Metropolitan Nashville Police Department

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The investigation into the mayor's affair came as the national outcry to call out sexual misconduct led to high-profile resignations from prominent elected officials and executives. Barry has said she doesn't want the affair to muddy the "Me Too" women's movement, since her affair was about middle-aged, consenting adults who had feelings for each other.

Shortly after the mayor's resignation, Forrest pleaded guilty to the same felony theft charge and agreed to reimburse the city $45,000 that was paid to him as salary or overtime when he was not performing his duties as the mayor's security detail.

The investigation found the photos in Forrest's work email and said they had been taken by his phone. There were also 260 deleted chats between Forrest's phone and Barry's phone number as well as 35 deleted call logs, an affidavit said.

The mayor agreed to reimburse the city $11,000. Both Barry and Forrest were sentenced to three years of probation.

"If you do what you're supposed to do you can have this matter dismissed and expunged," the judge told Barry.

Barry, 54, was riding high when news broke in late January that she had been having an affair with Forrest, whose wife filed for divorce soon after the affair became public. Barry acknowledged the affair but denied any wrongdoing and rebuffed calls for her resignation.

Barry's admission followed the painful loss of the Barrys' only son, Max, in July after an overdose on a combination of several drugs, including two opioids.

"This is a very bad day. And I'm going to have several more bad days. But this is not my worst day," Barry said in January. "And I will tell you I know the difference between a mistake — I made a serious mistake —but this is not a tragedy."

Sgt. Robert Forrest as he walks to the Criminal Justice Annex after Nashville Mayor Megan Barry resigned on March 6, 2018, in Nashville, Tenn. Mark Humphrey / AP

Elected in 2015, she had maintained a high profile in the city, appearing routinely at concerts and public events and spearheading a successful effort to bring professional soccer to Nashville. She was the point person for a $5.4 billion transit plan that Nashville voters will consider in a citywide referendum in May.

She hands over the reins to Vice Mayor David Briley, a liberal Democrat who ran unsuccessfully for mayor in 2007.

Metro Nashville Police records show Forrest's overtime more than doubled in the budget year after Barry was elected in September 2015. Barry said the affair began in spring 2016, according to an affidavit.

Barry has not said when the affair ended, only that it's over. Forrest, who had spent more than 31 years with Metro Nashville Police and supervised the mayor's security detail over three administrations, has retired.

The Tennessee Bureau of Investigation is looking into the matter and says its investigation "remains active and ongoing."

Briley was sworn in later Tuesday. A special election to choose a new mayor is expected to be held Aug. 2.

Briley, in a statement, called it "a hard day for Nashville" but said Barry's resignation "will enable us to regain focus on the important work of our city." He promised transparency and said he would work to restore the public trust.