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.
The performance followed the release on Thursday of her new single, You Need To Calm Down, which takes aim at homophobia.
Swift performed her hit Shake It Off at the bar in Greenwich Village with the evening's headliner, Modern Family star Jesse Tyler Ferguson.
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 ❤️ you! 🌈 https://t.co/ICE2b3arxU— Jesse Tyler Ferguson (@jessetyler)June 15, 2019
He later 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, responded: "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.
“Our country’s lack of protection for its own citizens ensures that LGBTQ people must live in fear that their lives could be turned upside down by an employer or landlord who is homophobic or transphobic,” Swift wrote on Instagram.
“The fact that, legally, some people are completely at the mercy of the hatred and bigotry of others is disgusting and unacceptable.”
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.
Swift has previously been criticised in some circles for remaining publicly apolitical during the last presidential cycle.
Last October, she surprised many by issuing an endorsement of Tennessee governor candidate Phil Bredesen, who ultimately lost, citing the controversy over the state’s LGBTQ legislation as one reason for speaking up.