A federal judge put Michigan Rep. John Conyers, one of the longest-serving Democrats in Congress, on the primary ballot Friday hours after state election officials declared him ineligible.
Earlier Friday, Conyers lost his appeal to get on the August primary ballot after state officials found problems with his nominating petitions.
But hours later, Detroit federal Judge Matthew Leitman issued an injunction ordering that Conyers' name be placed on the ballot.
Conyers needed 1,000 petition signatures to get a spot in the Democratic primary. But many petitions were thrown out because the people who gathered names weren't registered voters or listed a wrong registration address. That left him more than 400 short.
But Leitman's injunction said a Michigan law that puts strict requirements on petition circulators is similar to an Ohio law that was struck down as unconstitutional by a federal appeals court in 2008.
Leitman said the free speech rights of Conyers and the circulators were harmed, an argument pressed by the American Civil Liberties Union of Michigan.
There's evidence that the failure to comply with the law was a "result of good-faith mistakes and that (circulators) believed they were in compliance with the statute," the judge said.
Conyers, 85, told WXYZ-TV,"I'm trying not to smile openly much but this is very good news, and it's also good news for the process."
The first decision, from the Secretary of State's office, determined that Detroit-area officials were correct in keeping Conyers off the ballot, since he "failed to submit" a minimum of 1,000 signatures to qualify.
Wayne County officials had said there were problems with some people who collected signatures -- the circulators weren't registered to vote or had listed a wrong registration address.
Under Michigan law, that can spoil petitions.
Killing Conyers' career in such a way would be "pretty outrageous," his lawyer, John Pirich, said this week.
But an attorney for a Democratic challenger, the Rev. Horace Sheffield III, said Conyers for decades had no problem following the law.
"In essence, they played the game, lost and then complained that the rules were unfair," Eric Doster said, quoting a Virginia judge.
Conyers has spent 50 years in Congress and is the second most-senior member of the House, only to Rep. John Dingell, D-Mich., who is already retiring.
Fox News' Mike Emanuel and The Associated Press contributed to this report.