A mosque in Berlin on Friday became the first in Germany to fly a rainbow flag in support of the LGBT community, ahead of two major gay pride events in the city this month.

The Ibn Rushd-Goethe Mosque in the central Moabit neighbourhood unfurled the flag ahead of Friday prayers in front of a small crowd, including Berlin's culture senator Klaus Lederer.

Many of those attending wore rainbow stickers that read "Love is Halal".

The mosque, founded five years ago, is Germany's only self-described liberal mosque and allows men and women to pray together, as well as being open to LGBT worshippers.

Mo El-Ketab, one of six Imams at the mosque, said he wanted it to provide a "safe place for people who are different, so they too can experience the spiritual side of their lives".

A rainbow flag hangs outside the Ibn Rushd-Goethe mosque in Berlin
A rainbow flag hangs outside the Ibn Rushd-Goethe mosque in Berlin AFP / Adam BERRY

"I hope that many other mosques will also show the flag in this way or set other positive signs for the LGBT community," he said.

Two major events in support of the LGBT community will take place in Berlin this month -- the Lesbian and Gay Festival on July 16 and 17, and Christopher Street Day (CSD) on July 23.

Marc-Eric Lehmann, a CSD board member, said flying the flag sent "an incredibly strong sign" and it was "really important" to find a place for religion in LGBT communities.

"Queer people can also be religious and believe in God," he said.

"We should not just be talking about safe spaces in bars and clubs in Berlin, we also have to talk about safe spaces in the places of worship."