The Texas governor Rick Perry has been indicted for abuse of power after carrying out a threat to veto funding for state public corruption prosecutors.

The potential Republican candidate for president in 2016 is accused of abusing his official powers by publicly promising to veto $7.5m for the state public integrity unit at the Travis County district attorney’s office.

He was indicted by an Austin grand jury on Friday on felony counts of abuse of official capacity and coercion of a public servant. Maximum punishment on the first charge is five to 99 years in prison. The second is two to 10 years.

Perry said he would veto the funding if the district attorney, Rosemary Lehmberg, didn’t resign. Lehmberg had been convicted of drunken driving. Lehmberg refused and Perry carried out his veto.

A special prosecutor spent months calling witnesses and presenting evidence that Perry broke the law.

Perry’s general counsel, Marry Anne Wiley, defended the governor’s action.

“The veto in question was made in accordance with the veto authority afforded to every governor under the Texas Constitution,” she said. “We will continue to aggressively defend the governor’s lawful and constitutional action, and believe we will ultimately prevail.”

Several top aides to the Republican governor appeared before grand jurors in Austin, including his deputy chief of staff, legislative director and general counsel. Perry himself did not testify.

Grand jurors indicted Perry on abuse of official capacity, a first-degree felony with potential punishments of five to 99 years in prison, and coercion of a public servant, a third-degree felony that carries a punishment of two to 10 years.

A spokesman for the governor didn’t immediately return messages seeking comment.

No one disputes that Perry is allowed to veto measures approved by the legislature, including part or all of the state budget. But the left-leaning Texans for Public Justice government watchdog group filed an ethics complaint accusing the governor of coercion because he threatened to use his veto before actually doing so in an attempt to put pressure on Lehmberg to quit.

“I took into account the fact that we’re talking about a governor of a state and a governor of the state of Texas, which we all love,” said Michael McCrum, the San Antonio-based special prosecutor. “Obviously that carries a lot of importance. But when it gets down to it, the law is the law.”

In office since 2000 and already the longest-serving governor in Texas history, Perry is not seeking re-election in November. But the criminal investigation could mar his political prospects as he considers another run at the White House, after his 2012 presidential bid failed.

McCrum said he would meet Perry’s attorney Monday to discuss when he would come to the courthouse to be arraigned.

Lehmberg oversees the office’s public integrity unit, which investigates statewide allegations of corruption and political wrongdoing. Perry said he would not allow Texas to fund the unit while Lehmberg remained in charge.

Perry said Lehmberg, who is based in Austin, should resign after she was arrested and pleaded guilty to drunken driving in April 2013. A video recording made at the jail showed Lehmberg shouting at staffers to call the sheriff, kicking the door of her cell and sticking her tongue out.

Lehmberg faced pressure from other high-profile Republicans in addition to Perry to give up her post. Her blood-alcohol level was nearly three times the legal limit for driving.

Lehmberg served about half of her 45-day jail sentence but stayed in office, despite Perry’s assertions that her behaviour was inappropriate.

The jail video led to an investigation of Lehmberg by a separate grand jury, which decided she should not be removed for official misconduct.

The indictment is the first of its kind since 1917, when James “Pa” Ferguson was indicted on charges stemming from his veto of state funding to the University of Texas in an effort to unseat faculty and staff members he objected to. Ferguson was eventually impeached, then resigned before being convicted, allowing his wife, Miriam “Ma” Ferguson, to take over the governorship.