Sweden has hit back at Donald Trump after the US president reacted angrily to a decision to press assault charges against the American rapper A$AP Rocky, insisting its independent judicial system must do its work.

“The rule of the law applies to everyone equally and is exercised by an independent judiciary,” tweeted former prime minister Carl Bildt. “That’s the way it is in the US, and that’s certainly the way it is in Sweden. Political interference in the process is distinctly off limits. Clear?”

Trump said on Thursday he was very disappointed in Stefan Löfven for being unable to act. He said “Sweden has let our African American community down in the United States. Give A$AP Rocky his freedom.”

The US president also said: “We do so much for Sweden but it doesn’t seem to work the other way around. Sweden should focus on its real crime problem.”

The outburst followed an announcement earlier on Thursday by the prosecutor, Daniel Suneson, that he had filed charges against the rapper and two members of his entourage, “having come to the conclusion that the events in question constitute a crime and despite claims of self-defence and provocation”.

Rocky, 30, a platinum-selling, Grammy-nominated artist whose real name is Rakim Mayers and who is best known for his song Praise the Lord, has been in custody since 3 July while authorities investigate a fight he was allegedly involved in on 30 June before appearing at the Smash hip-hop festival.

Profile Who is A$AP Rocky? Show Hide 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

Other Swedish politicians also rebutted Trump’s comments, pointing out that the charges against the rapper were not arbitrary and wondering by what right Trump felt entitled to make such requests. “So, what is it you do for us, Mr President?” Fredrick Federley MEP tweeted.

Bildt told Aftonbladet newspaper that he though the government was “right not to get into a mud wrestling match with Trump. It’s his element, and should not be Sweden’s. [The government] has said what is has said, and that should be enough.”

Natalie Sial, a spokeswoman for the government in Stockholm, said it had nothing to add. “Now the judicial process will run its course,” she said.

Mayers, who has had to cancel more than a dozen dates on his planned European tour, has said was provoked and acted in self-defence. Footage on the celebrity news site TMZ shows him hurling a man to the ground as he and his entourage punched and kicked him. Other members of his entourage were filmed attacking another man.

Mayers subsequently posted a video on Instagram that showed him being followed by the two men who were later attacked, arguing: “We don’t know these guys and we didn’t want trouble, they followed us for four blocks.” Assault carries a maximum penalty of two years in jail in Sweden.

Suneson said this week it was “worth noting that I have had access to a greater amount of material than what has been available on the internet”. The decision to press charges means the rapper can be kept in custody until his trial, which is scheduled to start next Tuesday.

Celebrities including Kim Kardashian West and Justin Bieber have rallied behind the rapper and backed a #FreeRocky campaign. Mayers’ mother, Renee Black, this week called for her son’s release, telling the Expressen newspaper that he was being “made an example of”.

Kardashian West appealed directly to Trump to help Mayers, prompting the US president to tweet last week that he would “call the very talented Prime Minister of Sweden to see what we can do about helping A$AP Rocky”.

The two men spoke by telephone last Saturday. Trump tweeted that he had “offered to personally vouch for [Mayers’s] bail, or an alternative,” but Löfven issued a statement saying that “in Sweden, everyone is equal before the law” and the Swedish judicial system, prosecutors and courts were completely independent.