The speaker of Brazil's lower house of Congress is the architect of the impeachment drive which is expected to see Rousseff forced to step aside from office on Wednesday.
Cunha's dramatic setback was not expected to change the momentum against Rousseff, but yet again signaled Brazilian politics' descent into a whirlpool of corruption scandals and instability.
Despite facing criminal charges including bribery and hiding money in Swiss bank accounts, Cunha has survived months of attempts by prosecutors and a congressional ethics committee to see him brought to justice.
But the man Brazilians refer to as a real-life Frank Underwood - the corrupt US politician in the hit Netflix series "House of Cards" - appeared finally to have been brought down by Justice Teori Zavaski.
Also Read
The justice said that Cunha had obstructed justice "to prevent the success of investigations against him."
The ruling was a surprise, coming hours before the full Supreme Court was due to consider a separate attempt to have Cunha removed.
Zavaski said in his ruling "there is not the least doubt that the suspect does not meet the minimum personal requirements for fully exercising the functions of speaker of the chamber of deputies at this time."
"That qualifies him even less so for substituting as the president of the republic," the justice said.
Cunha's removal is considered unlikely to help Rousseff much, since she has already been badly weakened and her case is now in the hands of the Senate.
Rousseff is accused of manipulating government budget accounts with illegal loans, a charge which she describes as technical and not worthy of impeachment.
If she is suspended on Wednesday she will lose executive powers and be put on half pay pending the outcome of the trial, which could take several months.