The U.S. government warned Sweden of "negative consequences" as it advocated for rapper ASAP Rocky during his trial for assault charges in Stockholm this week, according to a pair of letters released by the Swedish Prosecution Authority.

Rocky was released from jail on Friday pending the verdict, with President Donald Trump celebrating the news on Twitter. "It was a Rocky Week, get home ASAP A$AP!" Trump said.

The rapper landed back on U.S. soil Saturday, leaving behind him the looming verdict in an episode that has led to unexpected tension between the U.S. and its European ally.

According to the letters, obtained by NBC News partner Aftonbladet, the U.S. special presidential envoy for hostage affairs wrote to Swedish prosecutors urging them to release Rocky.

"The government of the United States of America wants to resolve this case as soon as possible to avoid potentially negative consequences to the U.S.-Swedish bilateral relationship," Amb. Robert O'Brien wrote in the letter, dated Wednesday.

In response Sweden's prosecutor-general, Petra Lundh, defended the independence of Swedish courts and said she therefore had to deny O'Brien's requests.

"No other prosecutor, not even I, may interfere with a specific case or try to affect the prosecutor responsible," Lundh wrote in a letter dated Thursday.

The letters marked the latest intervention by U.S. officials in a case that has commanded the attention of figures ranging from the president to Justin Bieber.

Rocky, whose real name is Rakim Mayers, was arrested and charged with assault over a street brawl in the Swedish capital on June 30.

Trump began weighing in on the case last month following outcry from celebrities including reality TV star Kim Kardashian-West and musician Rod Stewart.

Trump said he spoke to Swedish Prime Minister Stefan Löfven asking for his release and "offered to personally vouch for his bail."

Löfven responded to Trump's public pressure, saying the rapper would not get special treatment and that the judicial system was free to act independently without political sway.

The two-time Grammy nominee was in Stockholm headlining Smash x Stadion, a two-day hip-hop festival. He was forced to cancel a flurry of shows on his European tour since his July 3 arrest after a judge determined he would remain in custody because he was a flight risk.

He pleaded not guilty on Tuesday as his high-profile trial kicked off.

O'Brien attended the hearings this week where Rocky told the court that he tried to handle the dispute peacefully and reason with two men who had confronted him before a brawl erupted.

Download the NBC News app for breaking news and politics

The U.S. envoy stressed that Washington was "grateful that I got to attend and observe the judicial process" in Sweden.

Following closing arguments on Friday, a judge ordered Rocky be released from jail pending the verdict.

Despite the U.S. offering assurances that Rocky would not leave Sweden if released, the judge ruled that the rapper could leave the country in the interim.

Rocky shared an emotional post on Instagram after his release, thanking fans for their support during this "very difficult and humbling experience."

A final judgment in the case is expected to be reached Aug. 14.

Read the letters