A federal judge in Michigan Friday ordered that Rep. John Conyers be put back on the ballot in the latest twist in a saga that jeopardized the political future of the Democrat who has served nearly 50 years in Congress.

U.S. District Court Judge Matthew Leitman issued an injunction ordering Conyers be placed on the ballot just hours after state elections officials upheld an earlier ruling that had kept him off for failing to secure enough valid petition signatures. At issue was whether a law requiring signature gatherers to be registered voters is constitutional.

Leitman said he was not issuing an opinion on that question Friday. But because the plaintiffs challenging the law had “shown a substantial likelihood of success” and “because time is of the essence,” Leitman said he opted to order that Conyers’s name be reinstated.

Leitman’s order came the same day the Michigan secretary of state’s office upheld a decision handed down May 13 by Wayne County Clerk Cathy Garrett. Garrett’s office ruled that Conyers submitted far fewer than the 1,000 valid signatures required to appear on the ballot.

Hundreds of signatures the Conyers campaign had gathered for the Aug. 5 primary ballot had been ruled invalid by the county clerk and secretary of state after a challenge by the Rev. Horace Sheffield, Conyers’s primary opponent, on the grounds the signatures were not gathered by registered voters. Hundreds more signatures were separately rejected.

Conyers’s attorney, John Pirich, said in a brief interview Friday that he expected the congressman to campaign as he normally would.

“We all look forward to Congressman Conyers being victorious in August and again in November,” Pirich said.

The state could appeal the ruling but the office of Attorney General Bill Schuette (R) said Friday afternoon that no decision had been made.

“We are reviewing the ruling in consultation with the secretary of state,” said Joy Yearout, a spokeswoman for Schuette.

First elected in 1964, Conyers is the second-longest-serving member of the House behind fellow Michigan Rep. John Dingell (D), who is retiring this year. Conyers represents a district that includes parts of Detroit and its suburbs.

The winner of the Democratic primary will be heavily favored in the general election, given the district’s liberal tilt. President Obama won 85 percent of the vote there in 2012.