Justin Bieber made a dramatic intervention into US politics on Saturday, comparing the plight of migrant children detained on the southern border to that of the the American rapper A$AP Rocky, who is in custody in Sweden over an alleged assault.

The White House is attempting to free A$AP Rocky, at the behest of Kim Kardashian and husband Kanye West, to the extent that Donald Trump has offered to “personally vouch for his bail”.

Rocky has been held for almost three weeks while Swedish authorities investigate allegations of “gross assault”.

Bieber tweeted: “I want my friend out. I appreciate you trying to help him. But while your [sic] at it Donald Trump can you also let those kids out of cages?”

The Canadian pop star was responding to a Trump tweet posted on Friday in which the president said he would engage in Rocky’s case.

On Saturday, Trump duly tweeted that he had “just had a very good call with [Swedish prime minister] Stefan Löfven, who assured me that American citizen A$AP Rocky will be treated fairly. Likewise, I assured him that A$AP was not a flight risk and offered to personally vouch for his bail, or an alternative.”

He went on: “Our teams will be talking further, and we agreed to speak again in the next 48 hours!”

Profile Who is A$AP Rocky? Show Named after one half of the hip-hop duo Eric B. & Rakim, Rakim Athelaston Mayers was born in New York in 1988. He adopted the name A$AP Rocky when he began his career in 2007, joining the A$AP Mob crew. Mayers had a troubled childhood. His elder brother was murdered, his dad was arrested for drug dealing, and he spent some time moving around homeless shelters with his mother and sister. His older sister died of a drug overdose in 2016. Mayers himself served two weeks in prison for drug dealing in 2004. He came to prominence with the release of the mixtape Live.Love.A$AP in 2011. Having signed to a major-label deal for a reported $3m, his 2013 debut album, Long.Live.A$AP debuted at No 1 on the US Billboard 200. Follow-up At.Long.Last.A$AP was also a No 1 album in the US, certified as a platinum seller, and featured a seemingly unlikely collaboration with Rod Stewart. His creative partner and best friend A$AP Yams (Steven Rodriguez) died in January 2015 in an accidental drug overdose. In 2016, Mayers became the first African-American to be the face of Dior Homme.

In 2013, he was charged with slapping a woman at Philadelphia's Made in America festival. This was eventually settled out of court in 2015. He has been involved in other altercations, in Toronto, New Zealand, and London, the latter involving a bagel and an Uber in Brick Lane. He unexpectedly declared a love of the Piccadilly Line while delivering the Red Bull Music Academy lecture in the city, and has collaborated with British rapper Skepta on the acclaimed track Praise the Lord (Da Shine).

He has caused controversy by appearing to describe the Black Lives Matter movement as a “bandwagon”, saying “I don’t wanna talk about no fucking Ferguson and shit because I don’t live over there. I live in fucking SoHo and Beverly Hills. I can’t relate.” Photograph: John Ricard/Getty Images

In Sweden, Löfven said he was glad to speak with the US about the rapper’s detention but he “cannot and will not attempt to influence prosecutors or courts”.

The Swedish leader said he was aware Trump “has a personal interest in the case” and described Trump’s desire for a conversation as “certainly positive”.

Löfven said: “I will explain that the Swedish judicial system is independent. In Sweden, everyone is equal before the law, and this includes visitors from other countries.”

A$AP Rocky, whose real name is Rakim Mayers, has been held by Stockholm police since 2 July, when he turned himself in. TMZ posted a video of him allegedly throwing a man across the street as a fight broke out.

In two posts on Instagram, two men can be seen following the rapper and his entourage on a Stockholm street. One of the men hits a security guard with what appears to be a pair of headphones.

Rocky wrote: “So a few drug addicts are not my fans. We don’t know these guys and we didn’t want trouble. They followed us for [four] blocks and they were slapping girls’ butts who passed.”

After a Swedish court ruled that he should be detained while the incident is investigated, the rapper’s manager, John Ehmann, complained that “conditions of the facility are horrific, and include 24/7 solitary confinement, restriction of amenities for the most basic of human functions, lack of access to life-sustaining food as well as

unsanitary conditions”.

Bieber, meanwhile, was trying to draw Trump’s attention to conditions in migrant detention centres at the border with Mexico, where reports have described children, families and single men held in squalid and sweltering conditions. The Trump administration’s inability or unwillingness to decently house migrants from Central America has fuelled an international outcry and a domestic political battle.

A$AP Rocky’s congressman, the New York Democrat Adriano Espaillat, said he had seen the tape of the incident which led to the rapper’s imprisonment. It was clear, Espaillat said, that Rocky was “provoked, and harassed, and followed, and accosted, and I think he acted in self-defense”.

Espaillat later accused Swedish authorities of using “KGB tactics”.

Ehmann said Rocky had been allowed to meet a US embassy official and a lawyer, “but only in the presence of Swedish officials. It is troubling and worrisome that the laws are not being applied equally.”

In a statement to Politico, the US state department said that said “there are certainly some facts about the arrest and detention that raise concerns”.