US artist Gilbert Baker, who is best known for creating the rainbow flag representing gay rights, has died at the age of 65.

The death of the San Francisco-based activist was announced by his long-time friend on social media.

"My dearest friend in the world is gone. Gilbert Baker gave the world the rainbow flag, he gave me forty years of love and friendship," author and fellow activist Cleve Jones said on Twitter.

Mr Baker died in his sleep at his home in New York on Thursday night, the San Francisco Chronicle reported.

According to the biography posted on his official website, he had been living in New York City.

Mr Jones also tweeted a photo of Baker with former President Barack Obama, inviting mourners to meet him under a rainbow flag in the Castro district of San Francisco on Friday evening to remember his friend.

The original flag included eight colours. Pink represented sexuality; red was life; orange was healing; yellow was sunlight; green was nature; turquoise was art; indigo was harmony; and violet was the human spirit.

The rainbow flag used today has just six stripes, with pink and indigo removed and turquoise swapped for blue.

Mr Baker, who was born in Kansas in 1951, was stationed in San Francisco in the early 1970s while serving in the US Army, at the start of the gay rights movement.

According to the website biography, he began making banners for gay rights and anti-war protests, often at the request of Harvey Milk, who would become the first openly gay man elected to public office in California when he won the 1977 race for a seat on the San Francisco Board of Supervisors.