JERUSALEM—Revelers dancing and singing through the streets of Jerusalem during the holy city’s annual gay pride parade were left shrieking in pain and panic Thursday night, as an anti-gay extremist lunged into a group leading the march and stabbed six people, Israeli police and witnesses said.

Police said the attacker, Yishai Schlissel, who was arrested at the scene, had been released from prison just three weeks ago, after serving a sentence for stabbing several people at the parade in 2005.

Six people were wounded in the attack, two of them seriously, Eli Bin of Israel’s emergency service said.

The parade was proceeding as planned with party music, Israeli flags and rainbow-clad marchers wending their way through central Jerusalem’s barricaded streets, under a heavy police presence.

An Associated Press photographer saw the attacker enter the throng of people with his hand in his coat and within seconds raise a knife and begin stabbing people in the back. Police pounced on him and arrested him.

The crowd’s carefree cheers suddenly gave way to screams. Panic ensued, and a bloody woman fell to the ground, the photographer said.

A man with blood seeping from his back wandered around with a dazed look before collapsing. Another man with his shirt off also had blood dripping down his back. Medics quickly surrounded them both and applied pressure to stop the bleeding.

Shocked revelers, some in tears, gathered along the sidewalk and hugged and comforted each other as ambulances and police on horses quickly arrived.

While the attack caused shock, it was not unprecedented: Schlissel was convicted of a similar stabbing attack that wounded several people at a gay pride parade in Jerusalem a decade ago.