HOW did Armistead Maupin end up here? How on earth did he become a successful novelist and activist living in a happy gay relationship in San Francisco? How did he end up as the writer of the beloved Tales Of The City novels, which follow a community of queers and hippies and eccentrics, all mothered by an elderly trans woman? And how on earth did he come to have a liberal, progressive view of the world? Because none of it should have happened. The odds were stacked against him. He should have been someone else.

What makes the 73-year-old writer’s life and career, and his status as a gay activist, seem so unlikely is where it all started. Armistead Maupin was a sensitive and gentle child but he grew up in a place where it isn’t always easy to be sensitive and gentle: North Carolina in the conservative south of America. In his new memoir Logical Family, Maupin reveals that, as a child, he would fall into guilty despair if he so much as killed a fly; fishing trips were also traumatic – the sight of a fish, flapping and gasping on the dock, dying alone, was a cause for great anguish, he says. There were also little signs of the gay boy he would become. “I enjoyed antiquing at a revealingly early age,” he says.

However, there was no time for sensitivity where Maupin grew up. His father was an unapologetic white supremacist who walked out in protest when the local preacher announced that he was ending racial segregation in his church. His father also had no idea of his son’s nascent homosexuality – in fact, Maupin remembers him telling him: “Don’t worry son. If you ever knock up a nigger gal, we can send her to Puerto Rico for the operation.” How do you grow up gay in that kind of environment?

The answer for Maupin – initially at least – was to put a lid on it, nail the lid down and then shout about how right-wing he was too. As a student, he made a speech defending racial segregation in restaurants and hotels on the grounds that people should be entitled to run their businesses as they saw fit. It was very much the argument you hear now from bakers who refuse to bake cakes for gay weddings and Maupin’s verdict on himself as a young man is fairly harsh: “He was callow all right, but his heart was still closed to the possibility of real tenderness. The lid was locked down for fear of what might escape.”

When I call Maupin at his home in San Francisco, I ask him about that the little conservative that he used to be and I wonder how it happens – are right-wingers made by their parents? “That was how I was made,” he says. “I had a white supremacist father that I adored and I believed everything he told me. That’s really why the book is called Logical Family because eventually you have to let your own decency take over and reject the ignorance that’s laid on you by your parents.”

Maupin has also observed that he is hardly the first gay man to hide on the right wing of politics. “Years ago in England, I said, ‘Scratch a Tory and you’ll find a homo’. I was wildly generalising but if you want to keep the lid on your own secret life, the best way of doing it is to insist others be as pure as you’re pretending to be.”

So what led to Maupin’s transformation from right-wing to left-wing? “The short answer is d***. I had deprived myself of sexual pleasure for so long that when I came to San Francisco and was able to embrace that, I found my humanity. If you’ve spent your entire life avoiding the touch of other human beings, a lot happens when you set yourself free and for me, all the other prejudices went with it when I stopped being prejudiced against myself. The bathhouses were remarkably democratic places – sometimes I was democratised until dawn. You find your humanity in those places – I can tell the difference between a bastard and a good guy in the dark. Left and right are just states of the heart – when you strip away all politics, left is openness and truth and kindness and compassion and right is a shutting down of the heart.”

Maupin’s move to San Francisco also, famously, led to his life as a writer and the stories that made his name. Tales Of The City started as a daily serial in the San Francisco Chronicle in 1976 and told the story of a naïve young woman, Mary Ann Singleton, who moves into a house run by an old lady called Mrs Madrigal, who is fond of handing out advice and neatly rolled joints. The serial, which also featured Mary Ann’s sweet gay friend Michael “Mouse” Tolliver, was a hit and eventually became a series of nine novels and several television series; it has also been a constant inspiration to many gay men and women coming to terms with their sexuality. Gay people read the novels and think: right, that’s it, I’m coming out.

Maupin is immensely proud of the books, but is particularly fond of Mrs Madrigal. When we first meet the landlady in the original novel, standing on her stoop amid wisps of incense and cannabis smoke, we know nothing of her childhood. Then gradually, over the course of the first few novels, we discover she grew up in a brothel and ran away to have a sex change.

At first, as Maupin explains in Logical Family, the editor at the San Francisco Chronicle was wary of the idea of a trans character and asked Maupin to delay revealing the fact. By the time Maupin did, readers had fallen in love with the character so that when they found out the truth they didn’t care. “The very fact that everyone got to see her humanity before they found out about her past allowed her to wiggle into their hearts and stay her. She is my most proudest creation.”

And rightly so: Mrs Madrigal has probably done more than any other fictional character to promote trans equality and understanding; she is also the queen at the heart of Maupin’s gentle, liberal view of the world, of people and of relationships.

Maupin has been with his husband Chris, a photographer, for 13 years, and, like one of the coincidences in his novels, met him on the street by accident after spotting him on a dating site. They are deeply close – so much so that he believes they can communicate in their sleep – but they also have an open relationship in which either of them can see other people.

I ask Maupin how that works. Open relationships were 10 a penny among gay men in the 1970s, but I wonder if they are quite so common now, given that gay people are standing up and taking marriage vows of monogamy just like straight people. “I think there are far more open relationships than people acknowledge,” says Maupin. “It embarrasses people to say that’s what they’ve worked out but I think frankly that’s one of the things that gay men have perfected. They’ve learned how to not make sex the deal-breaker in a relationship. It’s not the easiest thing in the world to do because it requires full honesty and kindness at all times and a certain amount of regulation but if you insist to the person you’re with that you will be their one and only until death, you’re probably headed in the direction of heartbreak because there will be lying involved.”

Maupin acknowledges that there are threats to this liberal, open view of the world – big threats like Trump and smaller threats, like Maupin’s brother Tony, who voted for him. “Those people wearing the red hats and wanting to make America great again they are just flat-out racists,” says Maupin. “I grew up with those people – I know who they are.”

As for Maupin’s brother Tony, he is one of those Trump supporters and is an opponent of gay marriage. “Imagine what it’s like for me to have members of my family who are still voting against marriage equality when I’ve been putting the word out for 40 years in a very public way. It became crystal clear to me that I was an embarrassment to him so I know how to remove that embarrassment and it’s going to be by not sticking around.”

Maupin says this is the message of Logical Family: you don’t need to stay loyal to your family if they’re not right for you. “You can divorce the hell out of them if they’re not changing,” he says. “It’s worth no-one’s time after a while. Get on with your life and find your logical family.”

Logical Family by Armistead Maupin is published by Doubleday at £20