Donald Trump has tweeted that the rapper A$AP Rocky has been released from custody in Sweden, where he was on trial for assault, and is returning to the United States following a court's decision not to keep him in custody.

The president, who has taken a personal interest in the case, 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!"

Earlier a court in Stockholm announced that the rapper - whose real name is Rakim Mayers - and two other men would be released from custody until August 14, when a verdict is expected to be announced.

The three are accused of beating up 19-year-old Mustafa Jafari in a street brawl in June, a charge they all deny.

Prosecutors have asked for a six-month prison sentence for Mayers, while the rapper told the court he thought community service would be a suitable punishment should he be found guilty.

Judges decided not to keep him in custody at the end of his three-day trial but it was not immediately clear whether he would be allowed to leave the country pending the verdict.

"Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Show all 13 1 /13 "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter holds up a T-shirt dismissing claims that the president and his party are racist during a campaign rally in Cincinnati, Ohio on August 1 Reuters "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Trump supporters hold up a T-shirt dismissing claims that the president and his party are racist during a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter reacts as Air Force One flies overhead outside of a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter wearing a Hillary Clinton mask peddles merchandise outside of a campaign rally in Cincinnati, Ohio on August 1 EPA "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter points to his T-shirt before the president takes the stage at a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter in a giant MAGA hat waits in line before a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Supporters of President Trump yell at protesters outside of a a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Protesters hold up signs during a campaign rally for President Trump in Cincinnati, Ohio on August 1 Reuters "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures A Trump supporter attends the presidential campaign rally in a fitting suit in Cincinnati, Ohio on August 1 Getty "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures President Trump addresses supporters from the podium at a campaign rally in Cincinnati, Ohio on August 1 Reuters "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Donald Trump Jr gives a thumbs up after speaking at a campaign rally in Cincinnati, Ohio on August 1 Getty "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures Supporters of President Trump wait in line to enter a campaign rally in Cincinnati, Ohio on August 1 AP "Blacks for Trump" applauded as supporters rally in Ohio: In Pictures President Donald Trump arrives back to the White House after a campaign rally in Cincinnati, Ohio on August 1 EPA

Mr Trump has previously called for the 30-year-old rapper to be released and sent a US government hostage negotiator to observe the trial.

Last week he tweeted that he was disappointed in the Swedish prime minister, Stefan Löfven, for not intervening in the trial to let Mayers go free. Mr Trump said: "Sweden has let our African American community down in the United States. Give A$AP Rocky his freedom."

In another tweet he wrote: "We do so much for Sweden but it doesn't seem to work the other way round. Sweden should focus on its real crime problem."

The former Swedish prime minister Carl Bildt was among those to remind Mr Trump that the judiciary is politically independent in Sweden and that "the rule of law applies to everyone equally", adding: "Political interference in the process is distinctly off limits. Clear?"

Some commentators have suggested Mr Trump is hoping for a good news story involving an African-American in order to offset the row over a series of racist comments he has made against Democratic politicians of colour.

It is not the first time that the US president has left politicians in Sweden baffled.

At a rally in Florida in 2017 he referred to something that had apparently happened "last night" in Sweden. He added: "You look at what's happening in Germany. You look at what's happening in Sweden. Sweden, who would believe this? Sweden! They took in large numbers. They're having problems like they never thought possible."