Some two million revellers are expected in Madrid starting Friday as the Spanish capital hosts WorldPride 2017, one of the biggest celebrations of lesbian, gay, bisexual and transgender rights.
Forty years after Spain's gay community started to march for its rights in Barcelona, Madrid is about to celebrate its openness to all people "regardless of where they come from, who they are, or who they love", city representative Berta Cao said.
But Spain wasn't always so welcoming of homosexuals.
During the nearly 40-year reign of dictator Francisco Franco -- whose rule was blessed by the church in heavily Roman Catholic Spain -- homosexual acts were illegal and thousands of gays were shipped off to rehabilitation centres, or even jailed.
Spain emerged from under Franco's conservatism in the late 1970s into an exuberant era of liberal reforms and social freedom, thanks in part to the struggles of residents in the Chueca district of Madrid, where the director Pedro Almodovar shot his first films, breaking ground with openly gay and trans characters.
Since then, Spain has become a world leader in gay rights, a trend that accelerated when former Socialist prime minister Jose Luis Rodriguez Zapatero came to power in 2004.
"We are better protected, we have practically achieved legal equality," said Jesus Generelo, president of Spain's National Federation of Lesbians, Gays, Transsexuals and Bisexuals (FELGBT).
"Today, we are better prepared to obtain social -- genuine -- equality."
In July 2005, the country became the third EU member, after the Netherlands and Belgium, to allow same-sex marriages with a new law that also legalised adoptions by gays and lesbians.
More than 35,000 same-sex marriages were recorded in Spain between 2005 and 2015.
In 2007, another law came into effect allowing transsexuals to change their name and official gender without having sex-change operations.
"We've never held a WorldPride festival that had as much institutional support," Juan Carlos Alonso, the event's coordinator, said.
Madrid wants this year's pride march to be remembered as the biggest ever, and has dedicated it to victims of discrimination in countries where gays, lesbians, bisexuals and transgender people live in fear of punishment or even death.
The organisers have singled out Chechnya, where reports emerged in March that authorities in the conservative majority Muslim Russian republic were imprisoning and torturing gay men.
"Speak up for all those in Russia who cannot speak for themselves," WorldPride organisers say on flyers.
Gay pride marches in the country are illegal, so WorldPride has asked its followers on Instagram to upload pictures of the parade but to geotag it to Moscow's Red Square.
Though the main event may be the July 1 parade down the Paseo del Prado, one of Madrid's broad central avenues, an international human rights conference with nearly 180 participants is also planned.
Former Iceland prime minister Johanna Sigurdardottir, described as the "first lesbian public official", is expected to attend, as is Salvadoran LGBT activist Bianka Rodriguez, who wants to highlight the plight of trans women in Latin America.
"Since the beginning of the year, more than 300 trans women have been assassinated in Central America," Rodriguez said.
A special session on people living with HIV and AIDS is also on the agenda with activists from Uganda, Armenia and Chile in attendance.
But while Madrid is known as one of the most gay-friendly capitals in the world, the country has not escaped discrimination.
From 2015 to 2016, Spain recorded a 36 percent rise in "hate crimes" tied to sexual orientation or gender identity.
Madrid has hosted a yearly pride march for decades, but this will be the city's first WorldPride festival. It was held in London in 2012 and Toronto in 2014; New York will be the host in 2019.
The agenda is jam-packed with open-air concerts and other events, including a play on the romantic relationship between Spanish poet and playwright Federico Garcia Lorca and his last partner, before Lorca was executed in 1936.
The annual "drag race" through Chueca with men in high heels, wigs and figure-hugging dresses is another must, as well as the Mr Gay World competition.