A judge approved the request by Mr. Ghosn’s new legal team at midday, but prosecutors immediately appealed the decision and a final ruling did not come until late in the evening.

In exchange for his freedom, Mr. Ghosn is required to remain in Japan and accept other conditions imposed by the court to prevent him from tampering with evidence or fleeing. The Japanese news media has reported that those conditions include giving his passports to his lawyers, residing in Tokyo, having no contact with others involved in the case, being monitored by security cameras at home and limiting his use of phones and personal computers.

As Mr. Ghosn’s case goes to trial, prosecutors may face steeper odds than usual. Typically, Japanese prosecutors have a 99 percent conviction rate of indicted defendants. But with a new lawyer, and the intense international attention on some of the flaws in the Japanese criminal justice system, “it’s increasingly looking like it’s not a slam dunk,” said Stephen Givens, an American corporate lawyer in Tokyo.

Mr. Ghosn’s decision to deny the charges against him can be a somewhat risky position to take in the Japanese justice system. The authorities in the country are notorious for using confessions, sometimes extracted under duress, to get convictions, and they are not used to being thwarted: In 2017, 88 percent of those who went to trial confessed, according to data maintained by Japan’s Supreme Court.

Receiving bail is itself unusual in Japan, but even more so for those who refuse to acknowledge guilt. Only around 25 percent of defendants in the country are released before trial. Of those who maintain they are innocent, only about one in 13 walks free, according to data from the Japan Federation of Bar Associations.

That makes Mr. Ghosn’s release unexpected, said Akira Kitani, a former judge now working as a defense attorney.

“Compared to the other cases in the past, this is definitely quick,” he said, noting that international attention on Mr. Ghosn’s case may have influenced the judge’s decision to release him.