NASHIVILLE, Tenn. — Before her sudden fall, former Nashville Mayor Megan Barry was a progressive, pro-business rising star among Tennessee’s struggling Democrats in a firmly red state.

She officiated the city’s first gay marriage before being elected in 2015. She pushed for tremendous growth, helping shape an ever-changing skyline of construction cranes and new high-rises.

When the Barrys’ only son died of a drug overdose in July, people across the country rallied to console her and her husband, Bruce. She was the face of a key ballot referendum coming up in May that will ask voters to shoulder tax increases to help build a $5.4 billion transit system.

But Barry’s quick political ascent seemed to hit the dirt on Tuesday after a wild, five-week freefall, as she pleaded guilty to stealing thousands of taxpayer dollars to carry on an affair with her former bodyguard and resigned.

Barry stunned the city in late January when she confessed to the extramarital relationship, which began in spring 2016 and continued as her popularity and accomplishments grew. She said the affair ended, but hasn’t disclosed when.

“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,” the 54-year-old Barry said at a news conference shortly after appearing before a judge. She did not take questions.

In court, Barry didn’t say how she stole money from the city, but investigators have said they believe she engaged in the affair while she was on city-paid trips and Forrest was on the clock. The district attorney’s office later said the restitution Barry agreed to pay as part of her plea deal was for Forrest’s travel expenses while he was on personal time.

Barry and her former bodyguard, police Sgt. Robert Forrest, separately pleaded guilty to felony theft. Barry’s resignation was part of a plea bargain with prosecutors. She and Forrest were sentenced to three years’ probation.

Forrest will return $45,000 that authorities said was paid to him in salary or overtime when he was not actually performing his duties as security chief.

A state investigation into the matter was closed after the pleas, essentially ending the case.

Authorities found two nude or partially nude photos of a woman that were taken by Forrest’s phone while he was on duty. The photos were shot last May and October, on days that Barry’s travel schedule shows she was on trips to Washington.

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

Vice Mayor David Briley, a fellow Democrat, said his car wouldn’t work Tuesday morning, so he decided to take the bus. Soon after, he learned he was about to become mayor.

After he was sworn in Tuesday evening, his first words were: “I need some coffee.”

He called Barry “a friend” and said he hoped she would be able to move past “a horrible moment” in her life.

Briley promised transparency and said he will work to restore the public trust.

A special election to choose a new mayor will be held Aug. 2.

Barry apologized when she revealed the affair in January. She denied breaking the law, rebuffed calls for her resignation, and said her husband remained committed to their marriage.

“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 then. “And I will tell you I know the difference between a mistake — I made a serious mistake — but this is not a tragedy.”

Barry had maintained a high profile in the city, appearing routinely at concerts and other events and spearheading a successful effort to bring professional soccer to Nashville.

Before becoming mayor, Barry earned an MBA from Vanderbilt University and was an ethics and compliance officer in the telecommunications and health care industries.

Forrest, who had spent more than 31 years with Metro Nashville Police and supervised the mayor’s security detail over three administrations, has retired. His wife filed for divorce soon after the relationship became public.

Police records show Forrest’s overtime more than doubled from 2014-15 to the 2016-17 budget year.

The new mayor, 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.”