AUSTIN, Texas—Travis County District Attorney Rosemary Lehmberg will remain in her post after a judge on Wednesday denied a petition to remove her because of an April drunken driving arrest.

State District Judge David Peeples, visiting from San Antonio, sided with Lehmberg. She will remain the county's top criminal prosecutor and continue to oversee Texas' Public Integrity Unit, which handles cases involving public officials and is based in Austin.

Lehmberg, who last year was elected overwhelmingly to a second four-year term, was arrested April 12 after deputies found her driving erratically and an open bottle of vodka in her Lexus. At the jail, a video showed Lehmberg shouting orders to call the sheriff, kicking the door of her cell and sticking her tongue out at deputies videotaping her.

That video led to an investigation by a grand jury, which decided she should not be removed for official misconduct. Lehmberg later pleaded guilty, was sentenced to 45 days in jail and entered rehabilitation upon her release.

She was pressured to resign but refused, and Travis County Attorney David Escamilla eventually sought her removal, arguing that Lehmberg was unfit for office and could harm the public interest.

Her lawyers, however, said Lehmberg is more than capable and has stayed in office out of a sense of responsibility to the public.

Taking the stand in her own defense during the civil court proceeding this week, Lehmberg said quitting would have been "the easy way out."

Shortly after Peeples ruling, Lehmberg said in a statement that she was "relieved and thankful that the process is over."

"I appreciate the many supporters, particularly within my office, who encouraged me along the way," she said. "I deeply regret my actions on April 12th and have taken full responsibility. I am committed to carrying out my responsibilities as District Attorney and to continue serving the voters of Travis County."

The matter is still not fully over. Among those who felt Lehmberg should have resigned was Gov. Rick Perry, who threatened to withhold nearly $4 million in state funding for the Public Integrity Unit if she remained on the job. When she refused, Perry made good on his threat, which resulted in a still-ongoing lawsuit from a watchdog group that claimed Perry had abused his power.