Planting Peace, a US-based non-profit group that seeks to "spread peace in a hurting world", launched the flag near Milwaukee, Wisconsin, on 17 August.
The balloon captured video with a GoPro camera as it floated 21.1 miles (34.1km) above earth for three hours.
Organisers said they wanted to declare space gay friendly, "in a peaceful, beautiful way".
The balloon and its flag returned to earth, but the episode was captured in striking footage that shows the planet's surface from above, with the sun beaming behind the flag.
The non-profit group said: "The primary purpose of this declaration is to support the ongoing fight for the fundamental human rights of our LGBTQ [Lesbian, Gay, Bisexual, Trans and Queer] family, moving us closer to a universal understanding that all people deserve to live freely and love freely without fear and discrimination."
It added that the stunt emphasised the need for the gay community to have a safe space in every corner of the universe.
As well as gay rights activism, Planting Peace runs humanitarian aid projects and environmental initiatives across the world.
It recently made headlines during the Republican National Convention in Cleveland, Ohio, with a billboard that showed US presidential candidate Donald Trump and then-aspiring Republican nominee Ted Cruz poised to kiss, with the slogan "Love trumps Hate. End homophobia".
"I'm gay - but I wasn't 'born this way'"
Modern Family features transgender child actor
The transgender Republican trying to change her party
The rainbow flag that symbolises gay pride has been sent into space for the first time via a high-altitude balloon.