Image copyright CBS Image caption Former Nashville Mayor Megan Barry (L) and former Sgt Rob Forrest (R)

The mayor of Nashville, Tennessee has resigned and pleaded guilty to theft from the city during a two-year affair with her police bodyguard.

Democrat Megan Barry, 54, had been seen as a rising star before she admitted to an extramarital affair last month.

Prosecutors say she racked up thousands of dollars in expenses with her head of security Sgt Rob Forrest. She initially denied abuse of taxpayer money.

Barry has promised to repay the city and serve three years' probation.

"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," Barry said on Tuesday shortly after a court appearance.

District Attorney Glenn Funk argued that she had improperly used between $10,000 (£7,000) and $60,000 (£43,000) in city funds while carrying out an affair with the head of her security detail.

Forrest's overtime pay more than doubled from 2014-15 to the 2016-17 budget year, according to Metro Nashville Police records.

Image copyright CBS Image caption Sgt Forrest (C) had been a constant presence alongside the mayor (R)

When the judge asked if the accusations were true, she responded: "Yes sir".

As part of her plea deal, she has agreed to repay the city $11,000 in restitution.

Forrest also pleaded guilty to the same felony theft charge and agreed to reimburse the city $45,000 shortly after Barry resigned.

Both Barry and Forrest had been married during the affair.

Forrest resigned from the force when the affair was first revealed in January.

But Barry - who was elected as the city's first female mayor in September 2015 - refused to quit, insisting that no professional misconduct had taken place.

"This is a consensual relationship between two middle-aged people who had feelings for each other," she said at the time.

According to the Tennessean newspaper, Barry and Mr Forrest attended 10 city-funded trips together without any other mayoral staff present.

The Tennessee Bureau of Investigations also found a nude photo and a partially nude photo of a woman that appeared to be taken on Forrest's phone.

The photos, which do not show the woman's face, were taken and then deleted while the sergeant was on duty. Barry has said if the photos were of her, they were taken without her knowledge.

The city's vice-mayor is due to be sworn in as mayor later on Tuesday.

Before the scandal broke Barry enjoyed a 70% approval rating, according to the Tennessean newspaper.

Barry made headlines last year after she revealed that her 22-year-old son had died from an opioid drug overdose in July 2017.

Media playback is unsupported on your device Media caption 'Our hearts will always be empty'

Tennessee Governor Bill Haslam called Tuesday a "sad and hard day" for the city.

"But Nashville has had a lot of great days in the past and will have a lot more in the future," Mr Haslam said in a statement.