Former Irish Olympics boss Pat Hickey has been told he can return home on health grounds - provided he pays more than €400,000 in bail.
The 71-year-old, who was arrested in his hotel in Rio de Janeiro during the Summer Olympics, is facing charges in relation to alleged ticket-touting.
However, a judge ruled yesterday that he can get his passport back.
The decision was made by Ms Justice Juliana Leal de Melo, of the Special Court for Supporter and Large Events in Rio de Janeiro, which had jurisdiction during the Olympic and Paralympic Games.
Her decision has since been published on the court's official website.
Mr Hickey has been ordered to pay a bail bond of R$1,500,000 (€410,753).
The judge recognised that there is a risk that he might not return for a trial, given the fact that he has no links to Brazil.
However, she balanced this by saying that the defendant needs to receive "health treatment" in his home country.
Along with the bail bond, Mr Hickey has been ordered to be available for the process.
The judge wrote: "Thus, certified the payment of the bail, hereby fixed, as well as rendered the commitment of cooperation with the justice by the defendant, I authorise the release of the passport of the same, as well as that the defendant leaves the country to treat his health."
Mr Hickey and THG Sports director Kevin Mallon are facing charges of ticket-touting, illicit marketing and money-laundering in Brazil.
Both deny all allegations made against them.
Mr Hickey was released two weeks after his arrest, but Brazilian authorities have kept hold of his passport until now.
Earlier, lawyers for both the accused had requested that the case be shelved, citing a "lack of just cause".
Mr Hickey has not yet reacted to the court's decision. It is understood he was informed of the judgment late last night.
A spokesperson for the former Olympic Council of Ireland (OCI) chief did not respond to calls from the Herald.
Last month, his solicitor Simone Kamenetz said that Mr Hickey was in grave need of emergency surgery.
"I can tell you that Mr Hickey is sick," she said.
"He suffers from atrial fibrillation, and the cardiologist who has seen him already two times, Dr Claudio Domenico, a well-known and reputable physician, established that Mr Hickey's situation is preoccupying.
"Mr Hickey must undergo a delicate heart procedure and he should be allowed to do it with his doctors that have been following his health conditions already for years, with his family alongside him."
At the time, Ms Kamenetz said that Mr Hickey would return to face the allegations against him once he had undergone treatment.
"This is a humanitarian issue," she said.
"Mr Hickey will not hide from the Brazilian justice, mostly because it is his desire to be totally cleared of all accusations.
"But if he is obliged to stay here in Brazil for years, he will not be alive to see the end of this case."