AUSTIN, Tex. — The last nine months of Rick Perry’s tenure as the longest-serving governor of Texas were supposed to be a political victory lap.

Greg Abbott, the Republican state attorney general, and Wendy Davis, the Democratic state senator, both of whom are vying to replace Mr. Perry, have been sparring across Texas. Meanwhile Mr. Perry has been traveling the country and the world promoting the robust Texas economy and bolstering his national profile as he considers another run for president in 2016.

Mr. Perry, who began serving as governor in December 2000 and who leaves office in January 2015 after deciding not to seek re-election, has gone to great lengths to show he is not the same man he was during his disastrous 2012 presidential bid, including wearing designer eyeglasses to enhance his statesmanlike appearance.

But in recent days, Mr. Perry’s final months in office have been interrupted by a political and legal problem at home, one that could haunt him on the campaign trail should he run for president and that his Democratic critics are using to accuse him of punishing his political enemies.