Stockholm, Sweden (CNN) A court in Stockholm has allowed A$AP Rocky to await the outcome of his assault trial in the United States, releasing the American rapper who has spent the past month in Swedish jail.

The Stockholm District Court has not yet made a ruling in the case, but said Friday that A$AP Rocky and his two co-defendants were free to leave Sweden. Rocky, David Rispers and Bladimir Corniel are currently on their way back to the US, according to a US State Department official.

A judgment will be delivered on August 14.

The 30-year-old artist -- whose real name is Rakim Mayers -- has been in custody since July 3. After his release, he thanked the court and his supporters in a message posted on his Instagram account.

"Thank you from the bottom of my heart to all of my fans, friends and anyone across the globe who supported me during these last few weeks," he said. "This has been a very difficult and humbling experience," he added.

The alleged victim in the case was "very satisfied" with how the trial had been conducted, according to his lawyer Magnus Stromberg.

"My client has nothing against these gentlemen. He wishes them all the best in life. He feels that he has been able to tell his view of events," Stromberg told reporters outside the court room. "We are very satisfied with the actual trial. Then we'll see what the court decides."

A$AP Rocky, right, leaves the district court after the third day of his trial in Stockholm on Friday.

His case had fueled a diplomatic quarrel after repeated interventions from US President Donald Trump, who publicly demanded the rapper's release, even raising the issue with the Swedish Prime Minister Stefan Löfven. Swedish authorities have repeatedly stressed that the country's judiciary is independent and that the government is "not allowed, and will not attempt, to influence the legal proceedings."

After the court's decision on Friday, Trump tweeted: "A$AP Rocky released from prison and on his way home to the United States from Sweden. It was a Rocky Week, get home ASAP A$AP!"

In theory, the rapper could still face a prison sentence in Sweden, as the prosecutor asked for a six-month prison sentence. However, the court said he will not be required to be in Sweden for the judgment hearing.

Slobodan Jovicic, A$AP Rocky's lawyer, said he was "satisfied." "We had two goals -- one goal was that my client was going to be a free man today," he said. "And then we are hoping for an acquittal in 14 days, but we have to wait and see."

The allegations against A$AP Rocky

A$AP Rocky was accused of committing assault during a June street brawl in Stockholm. He pleaded not guilty and has argued that he, Corniel, and Rispers were only defending themselves.

But prosecutor Daniel Suneson told the Stockholm District Court on Friday that he had proven the accused were not defending themselves and therefore could not claim self-defense. "In a putative self-defence situation, the violence must still be proportionate. Here we have three people delivering kicks and punches to a person lying down," Suneson told the court in his closing statement.

"The three should be convicted of assault according to my description of events," Suneson said, adding that previous sentences for such crimes ranged between six to 10 months in jail. The maximum penalty under Swedish law is two years in prison.

A$AP Rocky wore a dark suit in the third day of the trial.

The alleged victim told the court A$AP Rocky and his entourage assaulted him by kicking and beating him with a glass bottle or part of one while he lay on the ground.

The rapper himself, who was cross-examined by prosecutors on Thursday, admitted he briefly held a bottle during the altercation, but put it down without using it as a weapon. Jovicic has also said there was no evidence of the bottle hitting him.

The three suspects told the court they would accept community service if they had to. However, Suneson said that was not an option.

Renee Black, A$AP Rocky's mother, arrives at the courthouse on Thursday.

A high-profile trial

The trial had been moved to a special secure courtroom because of the huge media attention it attracted. However, Jovicic said the case shouldn't be handled in a special way. "When they ask me who is my client, I say Rakim Mayers, I never say A$AP Rocky. This is just like any other trial."

The trial was monitored from the courtroom by Trump's top hostage negotiator, Robert C. O'Brien, who also wrote a letter to the Swedish Prosecution Authority earlier this week, saying the US government wanted to "resolve this case as soon as possible to avoid potentially negative consequences to the US-Swedish bilateral relationship."

O'Brien's letter also asked for a humanitarian release from prison to a "supervised detention in a local Stockholm hotel pending final disposition of the case" -- a request rendered moot by today's ruling.

The letter was leaked to Swedish media and its authenticity was confirmed to CNN by the Swedish Prosecution Authority.

In a response to the letter, Petra Lundh, Sweden's Prosecutor-General, stressed the independence of the prosecutor, and said "no other prosecutor, not even I, may interfere with a specific case or try to affect the prosecutor responsible."

Following the decision, O'Brien said Friday was "a good day for the United States of America and a good day for the Kingdom of Sweden."

Correction: A previous version of this story misspelled Petra Lundh's surname