Taylor Swift treated fans to a surprise performance at an historic LGBT landmark in New York City.

The pop star marked Pride month by turning up at the Stonewall Inn, the site of the 1969 Stonewall Riots, a pivotal moment in the fight for LGBT rights.

Swift, who on Thursday released a single, You Need To Calm Down, taking aim at homophobia, performed her hit Shake It Off at the bar in Greenwich Village.

She was joined on stage on Friday by the evening’s headliner, Modern Family star Jesse Tyler Ferguson.

Following the performance, he tweeted: “I’m so happy I don’t have to keep this secret any longer.

“Look who came to celebrate the 50th anniversary of Stonewall at the Stonewall Inn. @taylorswift13, you are a gem.

“Thank you for everything you do for the LGBTQ community. We (heart) you!”

Swift, 29, added: “Thank you for having me Stonewall and happy Pride!”

Swift used to be criticised for her silence on political matters but since last year has become increasingly vocal on the issue of LGBT rights.

Earlier this month she urged her fans to write to their local senator to demand they back the Equality Bill, which, if passed, would introduce laws to protect the LGBT community in the US.

In You Need To Calm Down, a single from Swift’s upcoming seventh album, Lover, she sings “shade never made anybody less gay”.

The pop star praises the pro-LGBT group GLAAD.