The judge, Ruy Pinheiro, considered the detention of Diego Dzodan in Sao Paulo on Monday “unlawful coercion,” the court in Sergipe state said in a statement.
“It seems to me that the extreme measure of imprisonment was hurried,” Pinheiro said.
Facebook, which owns the popular WhatsApp mobile phone messaging tool, denies it has tried to obstruct the police probe.
Dzodan had been arrested on the request of a lower court judge in Sergipe and accused of “repeated non-compliance with court orders” to share Facebook data, federal police said.
“This information was required to produce evidence to be used in an organized crime and drug trafficking investigation,” police said.
According to Brazilian media reports, traffickers had been using WhatsApp to discuss their business.
When Facebook refused to comply, Brazilian authorities imposed fines, starting with 50,000 reais (about $12,500) daily beginning two months ago, and which rose to 1 million reais ($250,000) a month ago, Sergipe federal police told AFP.
US billionaire Mark Zuckerberg’s companies slammed Brazil’s approach.
“We are disappointed with the extreme and disproportionate measure of having a Facebook executive escorted to a police station in connection with a case involving WhatsApp, which operates separately from Facebook,” Facebook said in a statement.
“Facebook has always been and will be available to address any questions Brazilian authorities may have.”
WhatsApp insisted that it had no technical means for cooperating.
“We are disappointed that law enforcement took this extreme step. WhatsApp cannot provide information we do not have,” it said in a statement.
It’s not the first arm-wrestle between Brazilian justice authorities and Facebook.
In December, a judge ordered the suspension of WhatsApp for 12 hours after it failed to hand over information during another criminal investigation. The stoppage, which provoked widespread anger, was overturned on appeal.
Three years ago, Google was in the firing line. The search engine giant’s top Brazil executive was accused of breaking election laws when he refused to remove videos on YouTube that were critical of a mayoral candidate in Mato Grosso do Sul state.
In the United States, Apple is embroiled in its own row with the government over a refusal to cooperate with the FBI in unlocking an iPhone used by one of the shooters in a mass killing by a couple in San Bernardino, California, last year.