A sword-wielding assailant wearing a red “Make America Great Again” hat slashed a man in the hand during an altercation outside a popular roller-skating rink in San Francisco’s Western Addition on Friday, officials said.

Police are searching for the attacker, who fled the scene outside the Church of 8 Wheels on Fillmore and Fell streets, leaving his victim bleeding profusely on the sidewalk outside the crowded skating spot.

Investigators were searching for security video and speaking to witnesses Saturday as they tried to piece together the details of the bloody confrontation that unfolded during the rink’s Friday night adults-only roller disco.

Officers were called to the scene around 9:50 p.m. on the report of a stabbing, said Officer Robert Rueca, a San Francisco police spokesman. They learned that the victim, whose name was not released, had been approached by another man, who was wearing a “Make America Great Again” hat, and the two got into a verbal dispute, he said.

The victim tried to grab the hat, a symbol of President Trump’s 2016 presidential campaign, and the other man whipped out a sword and slashed him, Rueca said. Police originally reported that the victim was wearing the hat, but changed their statement late Saturday.

Scott Sweeney, 24, said he saw a man wearing the recognizable hat with a sword tucked into the back of his jacket about 30 minutes before the attack. The man, Sweeney said, was shouting homophobic slurs at him.

“In my mind I didn’t think it was a real sword until we came out later and police were on the scene and there was blood and the hat on ground,” he said.

David Miles, who goes by the nickname “Sk8father” and started the roller rink at the former Sacred Heart Catholic Church, was inside during the dispute. He said he didn’t see the attack but ran out to help the victim.

“I came outside. The guy was cut, he was bleeding like you wouldn’t believe,” Miles said Saturday. “He was just gushing blood, so we got the first aid kit from inside and tried to stop the bleeding.”

Paramedics quickly arrived and took the victim to a hospital, where he was treated for non-life-threatening injuries, police said. Miles said officers asked him if a man dressed as a pirate had come into the roller rink, but he hadn’t seen anyone like that.

Miles posted pictures of the bloody aftermath of the attack on Facebook, showing the red hat near a pool of blood. The victim had apparently chased his attacker before realizing how badly he was bleeding, he said.

“This is the last thing you think is going to happen,” he said. “I’m very, very, very concerned. I don’t really know what to think.”

Police are asking anyone with information about the attack to call investigators at 415-575-4444.

Gwendolyn Wu and Evan Sernoffsky are San Francisco Chronicle staff writers. Email: gwendolyn.wu@sfchronicle.com, esernoffsky@sfchronicle.com Twitter: @gwendolynawu, @EvanSernoffsky