US rapper A$AP Rocky has pleaded not guilty to assault at his trial in Sweden, saying he acted in self-defence in a case that has stirred diplomatic tension.

The 30-year-old rapper, whose real name is Rakim Mayers, was arrested on 3 July along with three other people following a fight in Stockholm on 30 June.

One of them, the rapper's bodyguard, was later released.

Part of the fight was captured in an amateur video published by US celebrity news outlet TMZ.

The rapper can be seen throwing a young man to the ground and then aiming several punches at him.

Mayers, who faces a jail term of up to two years if convicted of assault, has claimed he was acting in self-defence, saying he was responding to harassment and provocations by the plaintiff.

The trial began this morning at Stockholm District Court.

A$AP Rocky entered the courtroom with his lawyer Slobodan Jovicic.

The lawyer told the court his client acted in self-defence.

"He admits that he threw the plaintiff on the ground, that he stepped on his arm and punched or pushed his shoulder," Slobodan Jovicic told the court, but added that it was a case of "self-defence".

The rapper's mother Renee Black was earlier seen entering the court building.

The precise circumstances of the altercation remain unclear.

Before his arrest the rapper published videos of his own on Instagram purporting to show the lead-up to the fight.

In those, the young man can be seen arguing with the musician over a pair of headphones and the artist appears to repeatedly ask the man and his friend to stop following him and his entourage. One of the young men can also be seen hitting the artist's bodyguard.

A separate investigation into the plaintiff was dropped with prosecutors saying his actions were in self-defence.

Despite the rapper's own plea of self-defence, prosecutor Daniel Suneson decided to press assault charges against the musician and two members of his entourage on 25 July, stating that he believed what happened still amounted to a crime.

In announcing his decision to press charges, Mr Suneson stressed that he "had more material to consider than what has been available on the internet".

According to the charge document filed with Stockholm District Court, the evidence includes surveillance footage, witness testimony and text conversations.

The prosecutor says they prove there was no need for self-defence and that a bottle was used as a weapon in the alleged assault.

Photos of the alleged victim, taken by investigators, were published by Swedish media last week, revealing wounds seemingly caused by a sharp object.

Swedish law enforcement has also been accused of racism. Former US ambassador to Sweden Mark Brzezinski called the rapper's arrest a matter of "racial injustice".

A$AP Rocky's lawyer told a press briefing last week that he thought Sweden was "not a racist society".

On 5 July, Stockholm District Court ordered that the rapper be kept in custody while the case was being investigated. He has remained in a Swedish remand prison awaiting trial.

The musician, who had his breakthrough in 2011 with the release of the mixtape "Live. Love. A$AP", was on a European tour and has had to cancel more a dozen shows following his arrest, including the Longitude festival in Dublin.

Throughout his detention, fans, fellow artists and US Congress members have campaigned for his release.

An online petition called #JusticeForRocky has garnered more than 630,000 signatures, and social media campaigns encouraging fans to boycott Swedish brands such as IKEA have been launched.

The case has also seen repeated attempts at intervention by US President Donald Trump, who personally called Swedish Prime Minister Stefan Lofven to discuss the matter.

In a subsequent tweet, Mr Trump said he vouched for the rapper and offered to pay his bail, even though Sweden's justice system has no provisions for bail.

The district court deemed the rapper to be a flight risk and ordered his continued detention.

Mr Lofven's press secretary Toni Eriksson said "the prime minister was careful to point out that the Swedish justice system is completely independent".

Upon learning that the case would go to trial, President Trump vented his frustration on Twitter.

"Very disappointed in Prime Minister Stefan Lofven for being unable to act," Mr Trump tweeted, adding: "Give A$AP Rocky his FREEDOM."

Several Swedish politicians fired back at Mr Trump for trying to interfere in the judicial process.

"Political interference in the process is distinctly off limits! Clear?" former Swedish prime minister Carl Bildt tweeted.