STOCKHOLM – American rapper A$AP Rocky has to wait until Aug. 14 to hear if he has been found guilty of assault by a Swedish court, but he'll be freed while he awaits the judge's ruling.

He celebrated his release with an Instagram post on Friday.

"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 wrote. "I CANT BEGIN TO DESCRIBE HOW GRATEFUL I AM FOR ALL OF YOU."

Rocky, 30, called his incarceration in Sweden "a very difficult and humbling experience," and he expressed his gratitude to the court for allowing him to return home to his family and friends.

Los Angeles television stations reported the artist was among a group of people shown emerging from a private airplane at Los Angeles International Airport in footage broadcast late Friday night.

"THANKS AGAIN FOR ALL OF THE LOVE AND SUPPORT," he added.

A$AP Rocky, who was born Rakim Mayers, along with two other defendants from his entourage, Bladimir Corniel and David Rispers had pleaded not guilty and claimed they were acting in self-defense when they became involved in a street brawl with an Afghan immigrant in Stockholm on June 30.

They had been held in a detention center next to Stockholm's District Court since July 3, and their case sparked a diplomatic feud between President Donald Trump and Sweden's Prime Minister Stefan Löfven.

On Friday, screams of joy erupted in the courtroom from the three accused’s families when they learned the men would be released until Aug. 14. Rocky's mother shouted “there is a God.”

Trump tweeted Friday: "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!"

The case attracted global scrutiny after celebrities, including Kanye West and his wife, Kim Kardashian West, brought it to Trump's attention. Trump offered to post bail for A$AP Rocky. Sweden does not have a bail system.

Trump also implied in a series of tweets that the performer was treated unfairly in Sweden because he is black. Trump asked Sweden's leader to reconsider the detention order, but Löfven refused, pointing out the necessity of maintaining the integrity and impartiality of the Scandinavian country's judicial system. Trump appeared to push back on that by sending U.S. diplomat, Robert O'Brien, the State Department's special presidential envoy for hostage affairs, to the trial, an unusual move for a criminal case.

In an interview, O'Brien told USA TODAY that it was "entirely appropriate" for him to attend the trial despite it being a criminal case. "When foreign governments hold American citizens it's always appropriate," he added, when asked whether the move sent the wrong signal to Sweden's government, a longstanding American ally.

"The president sent me. That also makes it appropriate," he said.

O'Brien said Friday he has not had contact with Trump this week about the trial.

"We pleaded and we begged and we said, 'Look man, we don't want to fight y'all. We don't want any more problems. We don't want to go to jail. Please stop following us,' " A$AP Rocky told a packed courtroom during his testimony on Thursday.

Outside court, A$AP Rocky's fans and supporters played his music and broke into chants of "free A$AP, free A$AP."

Jerzy Sarnecki, a professor in criminology at Stockholm University, described Trump's effort to intervene on A$AP Rocky's behalf as "totally crazy." He said that if a Swedish national was arrested in New York on a criminal charge Swedish citizens would be outraged if their prime minister attempted to interfere with the U.S. legal process.

Over three days, the courtroom was shown surveillance footage, maps, photos and text messages that painted, at times, a confusing and contradictory account of what happened after Mustafa Jafari, 19, started talking to A$AP Rocky's bodyguard in Sweden's capital.

"To me they were just normal people. I didn't recognize them," Jafari said in his testimony. He insisted he approached the bodyguard for help finding a friend.

Grammy nominee A$AP Rocky said he believed Jafari was on drugs.

"I've heard speculation that I could demand damages and money and what not. I don't want any money. I can earn that money back. For me, what I want is justice. And I want my name to be cleared. And justice for all," he said, ahead of the verdict.

Contributing: The Associated Press