Reality TV star Hencha Voigt and former boyfriend, Wesley Victor, are accused of threatening to release explicit images of social media star Julieanna Goddard unless she paid a ransom.
The defendants said the ruling broke their constitutional rights.
But Miami-Dade Circuit Judge Charles Johnson said he was following the law.
"For me, this is like turning over a key to a safety deposit box," he said on Wednesday.
Prosecutors allege that Ms Voigt and Mr Victor told Ms Goddard to pay them $18,000 (£14,000) within 24 hours, or they would release X-rated videos and photos of her.
Ms Goddard, a party promoter and socialite, is a big name on social media where she goes by the name "YesJulz".
Ms Voigt is a model and Instagram star who appeared in WAGS Miami, a reality TV show about the wives and girlfriends of sports figures.
Police arrested the defendants last July and seized their phones, having intercepted text messages allegedly sent to Ms Goddard.
But they have been unable to bypass the passwords for Ms Voigt's iPhone and Mr Victor's BlackBerry to search for more evidence.
As a result, prosecutors formally asked the court to order the defendants to reveal their passwords.
Lawyers for the defendants said this would violate the Fifth Amendment - the part of US law that means people can not be forced to incriminate themselves.
But prosecutors cited a December court decision that allowed Florida police to force a suspected voyeur to give up his iPhone password.
On Wednesday, Judge Johnson ruled that he had no choice but to follow precedent. "That's the law in Florida at this point," he said.
Ms Voigt and Mr Victor have two weeks to comply with the order, or they could be jailed for contempt of court.
They have both pleaded not guilty to charges of extortion, conspiracy to commit extortion and unlawful use of a communication device.
The issue of whether authorities should have the right to access defendants' phones has sparked controversy recently.
Last year, the US Department of Justice ordered Apple to help unlock the phone used by San Bernardino gunman Rizwan Farook. But Apple fought the order, saying it would set a "dangerous precedent".
An apparent reported spike in demands by border officials to search visitors' phones when they arrive in the US also made headlines.
Department of Homeland Security data analysed by NBC News found that agents looked through almost 25,000 phones in 2016.