In 1976, Armistead Maupin had fallen in with Jack Coates, who had been Rock Hudson's lover for four or five years. Coates took Maupin and a group of friends to the San Bernadino Playhouse to see Hudson in a stage production of John Brown's Body. Then Coates led them backstage to meet the Hollywood star after the performance.

Armistead was one of the only men in the party not to have met Rock before. They got off to a fine start because they were no sooner shaking hands than a power failure plunged the dressing room into darkness. When Armistead murmured, clutching the big man's hand, "Well this is the opportunity of a lifetime," he was only half joking.

He knew he was in with a chance because it soon became clear that Rock liked his men manly. During their second encounter, when Rock and his lover, Tom Clark, passed through San Francisco in late May, Rock invited the half-a-dozen young men he'd dined with to join him for a nightcap in the Diplomat Suite of the Fairmont Hotel. "Rock already knew that the first episode of [Maupin's book] Tales Of The City would run in the Chronicle the next morning, so he secretly bought an early edition from the desk clerk and read it aloud to us up in the suite, rather drunkenly but with great charm."

Later, as the group was leaving, Armistead was startled to see Rock jovially consider and reject Steve Del Re, the pride of the Berkeley diving team, as too young. Then he invited Armistead to join him and Tom for dinner the following night.

Dinner was at La Bourgogne, a stylish French restaurant at the end of an alley in the Tenderloin district. Rock and Tom sat there tossing back Bullshots and even Armistead, who has always preferred dope to alcohol, became sufficiently plastered to offer to write the book about the star that would tell all. "And his lover was the one who raised the biggest hue and cry, saying, 'Not until my mother dies.' And I remember thinking, 'Who in the world would hide Rock Hudson from his mother?' As it turned out, Rock had been talking about The Book for years and the running joke was, 'Well, we'll save that for The Book.' "

As the three of them began to weave their drunken way back up Nob Hill to the Fairmont hotel, Tom Clark announced that he was too tired to walk and took a cab. Evidently this was part of a well established routine between the star and his former PR man for leaving Rock alone with the latest trembling young thing.

This latest trembling young thing (32 at the time) was in heaven. Rock had always been an icon of Armistead's and was not even slightly disappointing in the flesh: "He was a big man. He was completely and utterly charismatic. Rock was the perfect name for him. At 50, his butt was solid. And he was very charming and looked you straight in the eye. And he was desperately in need of giving you exactly what you wanted to hear, to the point that he would try to pass himself off rather touchingly as being interested in gay rights whenever I was around him. Clearly he didn't have a clue about gay rights... "

As they climbed the hill, Rock began jokingly thumbing rides from passing cable cars so that passengers started screaming, "It's Rock Hudson! It's Rock Hudson!" They arrived in the Diplomat Suite to find that Tom Clark had passed out in the bedroom. Rock led the way to the living room, fixed them both another drink. "We were both in suits and he sat across from me and we had a conversation for a while that was clearly about nothing to do with what was on our minds. And finally he said, 'Well, I should be over there or you should be over here,' which I thought was about the sexiest thing I had ever heard anybody say.

"I don't remember which one of us budged, but we did. And we had a sort of making-out session. We were finally rolling around on the floor when he said, 'Hang on,' and he produced a little black leather case that had R H embossed on it in gold. And he unzipped it and pulled out his poppers. He had a personalised Rock Hudson popper case! And I completely lost my hard-on. I was so overwhelmed at the notion that I was about to go to bed with Rock Hudson. Not to mention the fact that I'd just seen the baby's arm hanging between his legs. And we sat on the couch together and he put his arm around me and said, 'You know I'm just another guy, like any other guy. You know that, don't you?' And all I could say to that was, 'No. You're not. And I'm Doris Day.' "

The pair's later attempts were more successful. It wasn't a romance; they were becoming friends and sex was Hudson's chief way of expressing intimacy. But the restrictions of fame and the closet would ultimately cause that friendship to founder. "Quite a lot of famous people become curiously passive about the people they know and accept. Their hangers-on just call them and say, 'I'm in town,' and their house becomes a sort of hotel. And I could have done that continually and lived off the residual glamour, except that it wasn't very glamorous to be told that I would have to leave the house because Liz Taylor or Nancy Walker or somebody else he was playing bridge with was coming in the next day. As much as I liked Rock, I was just part of his sexual sub-life."

The encounters with Rock and the workings of the celebrity closet brought home to Armistead just how much he was growing in self-dignity as an out gay man. Having been a closet case himself only a few years earlier he suddenly found himself cast in the role of radical gay rights activist. "I started feeling my star was on the rise, so it was insulting to have to hide. I was building an identity for myself that was about telling the truth." In effect, Armistead had become one of the first American celebrities to be gay for a living and he sensed that, for all the lip service he paid to The Book, Rock was never going to come out.

Rock continued to get in touch on the occasions when he passed through San Francisco and on one such occasion Armistead successfully dared him to come cruising. "We started out at a disco and then we went to a leather bar called The Black And Blue that had a sort of orgy room in it. And he and I went back there and it was a lot of guys in black leather and Rock Hudson in a red alpaca sweater, looking like a tourist from the Midwest. And he stood there and nothing was happening. And I kept thinking, 'If they only knew what they're missing!' And I was standing next to him and beginning to feel that it was slightly sad that he was a wallflower at a Hell Ball so I pinched his butt in a friendly kind of way and he said, 'Is that you?' and I said, 'Yeah,' and he said, 'Just checking.' I'm now the age he was then, so I think I know what he was feeling that night, and it makes me feel closer to him."

Armistead paid homage to his fading friendship with Rock in Further Tales, while taking a hefty swipe at closet Hollywood, by having Michael Tolliver [a character in Tales of the City] link up with a closeted macho icon called _ _, popularly known as Blank Blank. To this day Armistead insists he was trying to write about closeted stars as a breed, not Rock in particular. Had outing him been his intention, he would have dropped far heavier hints in the narrative. As it was, he changed details that would have signposted Rock's identity too clearly. I remember many male readers wondering hopefully if Blank Blank was James Garner.

Then Rock came back into Armistead's life with a vengeance when the news broke - after his withdrawal from Dynasty and suddenly haggard appearance on Doris Day's cable pet show - that the star had Aids. A strange period ensued when the American media had no idea how to handle the story, whether to be saddened or scandalised, whether to play ball with Hudson's cronies and respect his privacy or tear the closet door off its creaking hinges.

"I think Mamie van Doren [a minor 50s film star] and I were the two people in America who were able to speak of him affectionately and be comfortable about his homosexuality. There were just a handful of people who would take on that job of saying, 'Yes. He's gay. He's very much loved. Everyone knew he was gay. The industry certainly knew he was gay. And don't you dare sensationalise this.' "

Armistead's decision to go public had long roots. He had known since 1982 or so that the nature of his life was such that sooner or later he would have a moral obligation to tell the truth because of the standards he had publicly set for himself. "There's really only one way to lift the stigma of homosexuality, which is to be matter-of-fact about it. So there was a very odd sense of the moment having arrived when this reporter from the Chronicle called me up and said, 'You knew him. How do you feel about this?' And I basically said what a terrible tragedy it was that this nice man who had played this horrible game all his life was finally revealed through a deadly illness. And it became the source that was quoted in the rest of the press so they could justify their own discussion of his homosexuality."

The weeks that followed were among the most stressful Armistead would experience. He was vilified in the gay press for what was seen as a betrayal of the home team. Outing had yet to be a word, even the concept was novel. Rock's sexuality was an open secret but one wasn't supposed to put it into words. "The old queen who ran the sidewalk flower stand on Castro Street clucked his tongue at me as I went by. Jack Coates, the guy who brought Rock into my life, called up weeping and drunk one night and said, 'How could you do that to that beautiful, beautiful man?' I knew that what I had done had come out of love and principle and in fact I had established a sort of template for the press that made things easier for Rock."

It was a turning point in media coverage of gay issues and in particular of Aids. Hudson was tantamount to American royalty and the impact of the story, from the White House down, was massive. People magazine ran its first sophisticated piece about gay life, using material Armistead fed them. Newsweek and the rest followed. At that stage, however, gay lobbyists, anxious not to see research and care funding severed, were desperate not to have Aids identified as a specifically gay phenomenon.

Armistead, meanwhile, had never felt so alone in his life. "In some weird way I felt guilt about it. I worried that I'd done something that had hurt him. I knew that morally what I had done was right, but the thought that he was in pain somewhere and about to die and had perceived my motives as being wicked in some way was really painful to me. I finally forgave myself in a dream. I had this very eerie dream where he walked in like a ghost, very thin but quite beautiful, with luminescent skin, and stroked the side of my face and said, 'It's okay, Buddy. It's okay.' "

In fact Rock effectively sent this message shortly before his death by telling his biographer Sara Davidson that Armistead was the first person she should visit. By the time of his death in 1986, Rock had received 35,000 letters of support. The Book, Rock Hudson; His Story, was to be written at last.

 Extracted from Armistead Maupin by Patrick Gale, published by Absolute Press at £6.99.