LONDON — Activists gathered for gay Pride in Istanbul Sunday in defiance of a ban by authorities, and despite riot police who used tear gas to disperse crowds.

Dozens turned up to wave rainbow flags and LGBT banners, watched by much larger numbers of Turkish riot officers as well as far-right protesters.

There were more than two dozen arrests, activists told NBC News, including at least one member of the media trying to cover the event.

Tear gas is fired at LGBT activists in Istanbul Sunday. Serdar Ocaksonmez

Pictures from the scene showed some of activists being arrested or being kicked by plain-clothes police, as well as tear gas being deployed. Activists said rubber bullets were also fired.

The march was banned — for the third year in a row — by the city governor, citing safety and public order fears.

“We are not afraid, we are here, we are not going to change,” organizers said in a statement. "Governors, governments, states change … we stay."

PHOTOS: Istanbul Police Enforce Ban on Pride Parade

The statement added: “We painted this street in rainbow for 12 years [and] showed the beauty of living and marching together to the whole world. We are here again, this time to show we will fight darkness for our pride.”

Police with riot shields and helmets enforced the ban by sealing off entrances to the main Istiklal Street, forcing activists to gather in various side streets.

Among those detained was Associated Press journalist Bram Janssen, who was covering the events, the agency said. He was later released.

Riot police block the way to Istikjlal avenue for an LGBT rights activist as they try to gather for a pride parade in Istanbul, Turkey on Sunday. Bulent Kilic / AFP - Getty Images

In total, 41 people were arrested including 28 activists, Pride organizers told NBC News in a statement. All the activists were later released.

Turkish authorities allowed Pride marches to take place until 2014, when up to 100,000 people attended, but the event was banned in 2015 and again in the past two years following threats from the ultra-nationalist Alperen Hearths group, which called Pride “immoral.”

Istanbul has traditionally been seen as a relative safe haven by members of the gay community from elsewhere in the Middle East, including refugees from Syria and Iraq.

But although homosexuality is not a crime in Turkey, unlike many other Muslim countries, homophobia remains widespread. Critics say President Tayyip Erdogan and his Islamist-rooted AK Party have shown little interest in expanding rights for minorities, gays and women, and are intolerant of dissent.