Editor's note: This story has been updated throughout.

A grand jury indicted Gov. Rick Perry on Friday on two felony counts, alleging he abused his power by threatening to veto funding for the state's anti-corruption prosecutors unless Travis County District Attorney Rosemary Lehmberg, who had pleaded guilty to drunk driving, stepped down from office.

The first count returned from a grand jury, abuse of official capacity, is a first-degree felony with a potential penalty of five to 99 years in prison. The second count, coercion of a public servant, is a third-degree felony with a penalty of two to 10 years.

Perry's legal counsel, Mary Ann Wiley, said Perry would vigorously fight the charges.

“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.”

David L. Botsford, another legal counsel for Perry, described the grand jury’s indictment as a “political abuse of the court system” that had no legal basis.

“I am outraged and appalled that the Grand Jury has taken this action, given the governor's constitutional right and duty to veto funding as he deems appropriate,” Botsford said in a statement released by Perry’s office.

The inquiry began last summer after an ethics complaint was filed alleging that Perry had improperly used a veto to deny funding for the unit, which is housed in the Travis County district attorney’s office and focuses on government corruption and tax fraud.

The indictment throws a major wrench in Perry's possible presidential ambitions; he was in Iowa last week and was expected in both New Hampshire and South Carolina in coming weeks. Perry is the first Texas governor to be indicted in almost a century. His office did not immediately return calls seeking comment.

Perry had been riding high and making national headlines in recent weeks, railing against the Obama administration for a perceived lack of response to the humanitarian crisis on the Texas-Mexico border, then reallocating funds to send National Guard troops there himself.

Now, he'll be playing defense.

TX Lege on Perry

Michael McCrum, the special investigator in the case, said he interviewed more than 40 people and reviewed hundreds of documents in the case. Perry never testified, and McCrum said he didn't subpoena the Texas governor.

"The grand jury’s spoken that at least there’s probable cause to believe that he committed two crimes, two felony crimes," he said.

He said that a time would be set up for Perry to come to court, be arraigned and be given official notice of his charges.

After Lehmberg pleaded guilty to drunken driving last year, Perry threatened to withhold $7.5 million in funding over two years for the integrity unit if Lehmberg did not resign.

Lehmberg, a Democrat, was sentenced to 45 days in jail but did not resign. Perry made good on his pledge and vetoed the state budget’s funding line item for the unit. Though Perry has the authority to veto items in the budget, his critics said that this was done expressly for political purposes and is a crime.

That was the rationale used by Texans for Public Justice, a left-leaning money-in-politics watchdog group that filed the initial complaint last June. The complaint said Perry was guilty of coercion of a public servant, official oppression and abuse of official capacity.

Perry’s office has repeatedly said that his veto was appropriate and that he violated no laws.

Texas Democratic Party Chairman Gilberto Hinojosa called on the governor to step down. Perry has "brought dishonor to his office, his family and the state of Texas," Hinojosa said in a statement.

Republican Party chairman Steve Munisteri said it was ironic that opponents are calling for Perry to resign, given that his indictment stems from trying to get Lehmberg to resign.

"I think most reasonable-minded people are going to be scratching their heads wondering what in the world is wrong with a governor who has veto power on appropriations saying he thinks it’s inappropriate to fund a unit where the head of that unit admitted that they had committed a criminal act and then compounded it by being on a video acting in an abusive way," Munisteri said.

The Austin-American Statesman reported in June that Perry would probably not testify before the grand jury, which has been meeting periodically for months, though several staffers from his office and from Travis County testified.

Last August, the Travis County Commissioners Court voted to provide some of the funding to the public integrity unit.

Lehmberg declined to comment on the indictments.

Jay Root and Terri Langford contributed reporting.