Nashville Mayor Megan Barry resigned Tuesday after pleading guilty to a felony that stemmed from an investigation into an affair she had with an officer on her security detail.

“My time today as your mayor concludes,” Ms. Barry, a Democrat, said in a press conference after her court appearance. “God bless this wonderful city. I love you, Nashville.”

She...