Rapper ASAP Rocky and two other American suspects have been temporarily freed from a Swedish jail and are planning to head back to the US.

The Stockholm District Court released the 30-year-old rapper, whose real name is Rakim Mayers, as well as David Rispers Jr and Bladimir Corniel until August 14 – when a verdict is expected in an assault case against them.

They are accused of beating 19-year-old Mustafa Jafari on June 30 outside a fast-food restaurant in central Stockholm.

The three suspects were seen hugging each other at the court after they learned they would be released as some of the public gathered outside the courthouse loudly cheered.

In a social media post the rapper thanked the court for allowing him to return home to his family and friends.

In a message to his 10.7 million Instagram followers he said recent weeks spent incarcerated had been “a very difficult and humbling experience”.

He wrote: “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.

“I can’t begin to describe how grateful I am for all of you. This has been a very difficult and humbling experience.

“I want to thank the court for allowing me Bladi and Thoto to return to our family and friends. Thanks again for all of the love and support.”

Mayers’ mother, Renee Black, who was present throughout the court proceedings, was with her son when he was released. A private plane was waiting at the Stockholm Arlanda Airport to transport the suspects and Black back to the US, according to the Swedish newspaper Aftonbladet.

Sweden Rapper
Renee Black, the mother of ASAP (Fredrik Persson/AP)

President Donald Trump, who had caused a stir in US-Swedish diplomatic relations after publicly offering support to the Grammy-nominated recording artist, celebrated Mayers’ release, tweeting: “It was a Rocky Week, get home ASAP ASAP!”

Swedish Prime Minister Stefan Lofven heard an appeal from Mr Trump earlier this week, but said he could not interfere in a legal case.

Robert O’Brien, a US special presidential envoy sent to monitor the court proceedings, stressed that Washington was “grateful that I got to attend and observe the judicial process” in Sweden.

The case has also drawn the attention of celebrities, including Sean “Diddy” Combs and Justin Bieber, and a social media campaign that was pressing for the rapper’s release.

Mayers’ release came after his three-day trial concluded.

One of the witnesses to the assault revised her story from initial police reports, saying that she did not actually see Mayers hit Jafari with a bottle — a key issue the trial focused on.

She and a friend, giving evidence anonymously at Stockholm District Court, both maintained their previous statements to police that they saw Mayers and his partners assaulting Jafari.

“Everything happened very quickly. We were scared for our lives,” the first woman told the court in Swedish. “He (Jafari) was bleeding. He showed his injuries on his hand. He also said he had a sore back.”

The rapper pleaded not guilty at the start of the trial Tuesday, saying he acted in self-defence when Jafari and another man would not leave them alone. He had been behind bars since he was arrested on July 3.