The parade at the center of Berlin’s gay Pride celebration on Saturday was a sunny blur of glitter and feathers, of rainbow flags and thumping techno beats. It was cocooned by walls of metal barricades and guarded by 2,200 police officers — up from 1,300 last year, as the city tried to curb a wave of violence against Berlin’s gay community.

Those precautions failed to prevent an attack late Saturday night, when an assailant plowed a rented van into a group of revelers leaving the celebration via a side street in the city’s central Tiergarten park, just outside the security perimeter. He attacked others with what appeared to be a machete, shocking those who thought the extra security measures might protect them.

“How did he even get into the Tiergarten?” asked Benjamin Bock, an attendee who said he had been at the site of the attack 10 minutes before it happened. “There were anti-car and anti-truck barriers everywhere. Thousands of police officers were on duty.”

One woman was killed, and 29 people were injured, the authorities said. The police shot and killed the main suspect on Sunday evening, ending a daylong national manhunt. Officials called the attack Islamist terrorism, and named the suspect as Abdul B., 21, omitting his surname in line with German privacy laws.

It was a sum-of-all-fears moment for Berlin’s L.G.B.T.Q. community and for city officials, who ramped up security at Pride events in recent years, and who had appeared to be making progress in their efforts to stem a surge of crime against the community.