SAN DIEGO – Maureen O’Connor was a physical education teacher who won a seat on the San Diego City Council when she was only 25 years old, later winning two terms as the city’s first female mayor — a Democrat who charmed voters with a populist flair.

But her rapid rise was matched by her fall, culminating Thursday when she acknowledged in federal court that she took $2.1 million from her late husband’s charitable foundation during a decade-long gambling spree in which she won — and lost — more than $1 billion.

O’Connor pleaded not guilty to a money laundering charge in an agreement with the Justice Department that defers prosecution for two years while she tries to repay the foundation and receives treatment for gambling.

O’Connor, 66, once had a personal fortune that her attorney estimated between $40 million and $50 million, inherited from her husband of 17 years, Robert O. Peterson, founder of the Jack in the Box Inc. fast-food chain. She is now virtually broke, living with a sister.

O’Connor walked across the courtroom with a cane, appearing frail and struggling to maintain composure at one point as her attorney wrapped his arm around her shoulder and placed his hand on her head.

At a news conference, she said she always intended to repay the foundation and appeared to blame her behavior on a brain tumor that was diagnosed in 2011.

O’Connor’s game of choice was video poker at casinos in San Diego, Las Vegas and Atlantic City, N.J.

Her attorney, Eugene Iredale, said she played for hours at a time.

She won about $1 billion from 2000 to 2009, according to winnings that casinos reported to the Internal Revenue Service, but lost even more. Iredale said her net gambling losses topped $13 million.