Patrick Haggerty, who in 1973 released an album of country songs about same-sex romance that sold only 1,000 copies and seemed destined for eternal obscurity until, four decades later, its rediscovery brought him renown as the first openly gay country singer, died on Oct. 31 at his home in Bremerton, Wash. He was 78.

The death was confirmed by his husband, Julius Broughton. He said Mr. Haggerty had suffered a stroke on a flight to Seattle on Sept. 30 after a show in Oakland, Calif.

The country music of Mr. Haggerty’s youth hardly acknowledged the existence of homosexuality, and when it did, the references were oblique and mocking. Billy Briggs’s “The Sissy Song,” released in 1951, proposed killing oneself as the adequate response to such unmanly habits as wearing the “pretty suede shoes that a lot of those sissies buy” and eating salad.

A concatenation of many things gave Mr. Haggerty the unusual — he frequently called it “absurd” — inclination to make gay country music.

He had been inspired to come out of the closet after learning about the 1969 Stonewall uprising in New York, credited with igniting the gay-rights movement. He soon joined a local Seattle chapter of the Gay Liberation Front, which helped form a gay community center and held demonstrations.

In 1972, he launched himself on what would become his most enduring form of activism: creating a band called Lavender Country, essentially a solo project in which he got help from a few friends in Seattle. He wrote most of the songs, played acoustic guitar and sang lead on the group’s debut album, also called “Lavender Country,” which was sponsored by a local gay social services group.

It was musically traditional: Mr. Haggerty sang with a twang, and the ensemble of piano, fiddle and acoustic guitar played comfortingly repetitive melodies. The music sometimes made for a contrast with the lyrics, which could be campy — “Back in the Closet Again” imagined a revolution in which “a battalion of gay men brought up the rear/Packing two grenades in each brassiere” — but there were also songs of protest and lament.

Addressing a closeted lover in “Georgie Pie,” Mr. Haggerty asked: “Would your Adam’s apple flutter,/Would both knees turn to butter,/Would you sputter, would you mutter and deny?”

Lavender Country attracted local attention, performing at gay pride parades in Seattle and San Francisco and eventually selling out a run of 1,000 copies of its album. But none of that constituted a living, and after a few years the group disbanded.

Mr. Haggerty became a hippie — living in communes, subsisting on food stamps, taking odd jobs like nude modeling. He had a short career as a social worker and supported himself by renting out rooms of his house in Seattle.

Mr. Broughton did not learn of Lavender Country’s existence until he and Mr. Haggerty had been dating for three years, and even then it was thanks to a stroke of luck. Around 1990, Mr. Broughton was leafing through a friend’s record collection when the name “Lavender Country” caught his attention. He asked his friend what it was.

“‘That’s Patrick’s album,’” Mr. Broughton recalled the friend telling him. “I said, ‘Patrick’s what?’”

Mr. Broughton asked Mr. Haggerty about Lavender Country. “That’s part of the past,” Mr. Haggerty replied. “It’s a dead subject.”

But his view began to change in 1999, when The Journal of Country Music published an article that called Mr. Haggerty “the lost pioneer of out gay country music.”

It prompted him to try to relaunch Lavender Country, but he wound up settling on a more modest musical comeback: playing country standards at nursing homes around Bremerton, a small city on the Puget Sound.

The bigger comeback began in 2013, when Brendan Greaves, whose indie label Paradise of Bachelors specializes in reissues, found Mr. Haggerty’s phone number and called him. Mr. Greaves said he considered Lavender Country’s music important and worthy of reintroduction to the public, but Mr. Haggerty questioned Mr. Greaves, a straight man, about his intentions. For a moment the conversation grew tense.

But when the call ended, Mr. Haggerty was so moved that he burst into tears. And he happily struck a deal with Mr. Greaves.

The reissued album went on sale in 2014, accompanied by a chapbook that included an autobiographical interview with Mr. Haggerty, photos of him and transcriptions of his lyrics. It earned a “best new reissue” designation from the online music publication Pitchfork.

The popular singer and drag queen Trixie Mattel went on to cover Mr. Haggerty’s ballad of gay cruising, “I Can’t Shake the Stranger Out of You.” Mr. Haggerty became the subject of a documentary that won a prize at the 2016 South by Southwest film festival in Austin, Texas. And in February, backed by a new supporting band, he released “Blackberry Rose.” Lavender Country’s first new album in 49 years.

The world had changed: Now a major country star like Brandi Carlile can be in a gay marriage, and an openly gay man like Lil Nas X can have a country hit with “Old Town Road.”

Mr. Haggerty began touring, performing his decades-old music. Wherever he went he found young musicians, many of them gay or transgender, to accompany him.

“For years I was by myself,” he told Billboard in 2021. “Now I have an entourage of country performers who think I’m their grandpappy.”

In 2014, at a Los Angeles show to celebrate the album reissue, he made an arresting discovery: The concert had attracted “a sea of young heterosexuals,” he told the Seattle alternative weekly The Stranger.

“I have never played to a more attentive and respectful audience in my life,” he said. “It blew me away. They were ready to hear it.”

Patrick Ambrose Haggerty was born on Sept. 27, 1944, in the small coastal city of Hoquiam, Wash. His parents, Charles and Asylda (Remillard) Haggerty, worked as tenant dairy farmers outside the Washington town of Port Angeles.

Along with his 10 siblings, Patrick shoveled manure and did other farm chores. He sang country classics like “Your Cheatin’ Heart” at family gatherings.

In other ways, Patrick stood out. He won a statewide cooking contest as the only boy contestant among hundreds of girls. He auditioned, successfully, for head high school cheerleader, in drag.

His father — a snaggletoothed farmer wearing a beat-up fedora — attended the tryout. Patrick saw him there and avoided him until it was time for the two to return to the family farm.

“Were you proud of yourself with that glitter up all over your face and your lipstick smile from ear to ear?” Mr. Haggerty recalled his father asking. He felt nervous and did not reply.

His father, he said in the Lavender Country documentary, continued: “If you sneak, it means you think you’re doing the wrong thing, and if you spend your whole life sneaking, you’ll spend your whole life thinking you’re doing the wrong thing — and if you do that, you will ruin your immortal soul.”

The father said that if Patrick was proud of himself, then he would be proud of Patrick. The elder Mr. Haggerty died soon thereafter, when Patrick was 17.

After he earned a bachelor’s degree in sociology from Western Washington University in 1966, he joined the Peace Corps; he was kicked out the same year for being gay. The Haggerty family doctor sent him to a mental hospital, but he checked himself out when he realized that he was not going to be cured of homosexuality.

Mr. Haggerty came to embrace radical politics, running unsuccessfully in 1991 for the Washington State Senate as a socialist on what he called “a Black-Gay unity slate,” joined by members of the Nation of Islam.

In addition to Mr. Broughton, he is survived by a daughter, Robin Boland, whom he fathered with Lois Thetford, a lesbian friend; a sister, Judy Haggerty; two brothers, Tim and Peter; and a grandson. He also helped raise Amilcar Navarro, the son of a friend of his.

Mr. Haggerty’s Lavender Country shows featured cursing, sexual innuendo and political invective. He often played with punk musicians. Yet in almost every show, the old rebel in a lavender cowboy hat brought up an unexpected subject.

“He would say, ‘I owe this music to my father,’” Mr. Broughton recalled, “‘because my father encouraged me to be who I am.’”