Image copyright Getty Images

Public buildings and street demonstrators around the world have flown rainbow flags to show solidarity with the 49 people shot dead in a gay nightclub in Orlando, Florida. How did this symbol become so widely recognised?

It's among the best-known political symbols in the world. The six-bar rainbow flag is regularly flown and held aloft in demonstrations in cities around much of the world.

Figures as diverse as Paul McCartney - who draped himself in one during a concert in Berlin - and the leaders of Moray Council in north-east Scotland - which raised it over its headquarters - have used it to show they are at one with the families and friends of the people gunned down in Orlando's Pulse nightclub.

A rainbow flag is to be raised above Exeter cathedral while a vigil takes place on Friday for the victims. Similar commemorations have taken place at baseball games in the US, while Paris's Eiffel tower has been illuminated in the colours of the flag.

Image copyright other

"I can't think of any other symbol that has such global recognition and adoption," says human rights campaigner Peter Tatchell. "Since the early 1990s it's become ubiquitous.

"It shows the diverse spectrum within the LGBT (lesbian, gay, bisexual and transgender) community, but also reflects the diverse spectrum of the wider community."

The rainbow flag's adoption as a symbol for the LGBT community dates back to 1978, when San Francisco-based artist Gilbert Baker released his original eight-colour design. The first hand-sewn versions flew on 25 June, Gay Freedom Day.

Baker has said he wanted to convey the idea of diversity and inclusion, using "something from nature to represent that our sexuality is a human right".

The flag's use spread from San Francisco to New York and Los Angeles. By the 1990s, it was recognised as a global symbol for LBGT rights.

"It replaced the use of the pink triangle, which was itself reclaimed from its use as a symbol of oppression in Nazi Germany," says Tatchell. "The rainbow flag is a more positive, uplifting symbol."

The eight different colours of Baker's original flag each represented a different aspect of life. These were:

Pink - sexuality

Red - life

Orange - healing

Yellow- sunlight

Green - nature

Turquoise - art

Indigo - harmony

Violet - human spirit

The number of stripes was later reduced to six. Blue replaced turquoise and pink and indigo were removed.

"It was quite hard to get hold of the hot pink material at the time," says Graham Bartram, chief vexillologist at the Flag Institute. "So it was discarded. In those days you had to sew flags together out of existing materials rather than print them out, as happens now.

"The reason the rainbow flag has caught on so well is its simplicity, which allows it to be so inclusive. It works a bit like the Olympic rings, which were designed to feature colours used in the flag of every participating nation."

Had Baker added more images related specifically to male homosexuality - such as the "double Mars" symbol, showing two interlinked circles with protruding arrows - his flag would not have succeeded in the same way, says Bartram.

The design isn't universally welcomed as a symbol of liberation. The attorney general of Jamaica, which has laws criminalising gay sex, has complained about the raising of the rainbow flag above the US embassy in the country following the Orlando shootings, arguing it is "disrespectful".

The rainbow flag has a long and diverse history. The 18th Century revolutionary Thomas Paine suggested using one to identify neutral ships during periods of warfare.

In the early 20th Century US peace campaigner James William van Kirk designed a flag showing rainbow stripes connected to a globe. It was intended to show how people of different nations and colours could live together in harmony.

And a rainbow features on the flag of the International Co-operative Alliance.

"The rainbow is something we all draw from a young age," Bartram says. "So we all know it and can read into it what we like. That's why it works."

Subscribe to the BBC News Magazine's email newsletter to get articles sent to your inbox.