A California man accused of slashing someone with a sword after his "Make America Great Again" hat was swatted off his head was charged with attempted murder, mayhem and assault with a deadly weapon on Friday.

Leor Bergland, 30, appeared in San Francisco Superior Court following his Wednesday arrest, according to the San Francisco Chronicle.

Bergland was arrested in connection with the slashing outside a roller-skating rink last week that reportedly occurred after the victim, 27-year-old Gabriel Gaucin, knocked the red "MAGA" hat popularized by President Trump's campaign off Bergland's head.

According to prosecutors, after Gaucin knocked the hat to the ground, Bergland allegedly "reached back, as if to punch the victim, but instead quickly brought his hand down, holding what the victim thought was an umbrella or nightstick."

David Miles, owner of the Church of 8 Wheels roller-skating rink, posted a photo on Facebook showing the iconic red hat next to a pool of blood outside the establishment. It quickly garnered attention.

Prosecutors described it as "one of the most gruesome photos of an assault I've ever seen," the newspaper reported.

Gaucin suffered a partially severed hand and was taken to a nearby hospital for emergency surgery.

A witness to the slashing reportedly tried to chase the assailant before he disappeared into a nearby park, officials said. Police then seized the red hat and a beer bottle the suspect had been seen drinking from at the scene, according to the paper.

A sword wrapped in a red plaid vest was discovered jutting out of a garbage can two days later, prosecutors said. Officials later matched a fingerprint from the beer bottle and arrested Bergland on Wednesday.

"No one has a right to strike someone with a sword because their hat was knocked off their head," Alex Bastian, a spokesman for the district attorney's office, told the newspaper. "Those are the allegations in this case and those things will be figured out in court."

The defendant has reportedly denied the incident and claimed he was at home during the attack, the Chronicle reported. He did not enter a plea during his court appearance, and his bail was set at $250,000.

The red cap has been a polarizing symbol of Trump's campaign and has sparked conflict since his 2016 election.

A California woman lost her job this week after she confronted a man wearing a "MAGA" hat.