Rufus Wainwright was 3 years old, playing in the shallow end of a pool at the Chateau Marmont. The famous West Hollywood hotel was “kind of a dump” in those days, and a quasi-home to troubadours like Leonard Cohen and Wainwright’s parents, Loudon Wainwright III and Kate McGarrigle. Wainwright’s Irish nanny wasn’t paying attention when he suddenly went underwater — “and was presumably saved by Betty Buckley,” he said, laughing.

“Which is the story I stick by. It’s amazing how certain childhood traumas really inflict themselves indelibly on your memory.”

He told that story over lunch, pre-pandemic, in the same courtyard of the same hotel. A few days later, I got an email back from Buckley. “Yes, I saved Rufus from drowning when he was a little kid,” the Tony-winning “Cats” singer wrote. She didn’t know who he or his parents were at the time, and only recently heard about him telling this story onstage. “I was beyond thrilled to learn that I had actually saved Rufus Wainwright!” she wrote. “I’m a huge fan.”

This is Wainwright in a bottle: dramatic, humorous and in proximity to musical legends. The singer-songwriter, who is just about to turn 47, is using his creeping middle age to reckon with his past and future on a new album, “Unfollow the Rules.”

The title, also the name of a torch ballad on the record, was conceived by his young daughter, Viva — the granddaughter of Leonard Cohen by way of the late poet’s daughter and Wainwright’s childhood friend, Lorca Cohen. The song “perfectly illustrates the philosophy of this record, which is, ‘Don’t give me what I want, just give me what I’m needing,’” he said, quoting the lyrics.

“You’re never going to get the answer to the questions. And these kind of magical dreams that you have are great and wonderful, but that’s not really what’s going to sustain you as a human. And I don’t know how you’re going to get to the next step, but you just have to get there.”

This Rufus Wainwright is sober and battle-hardened after getting roughed up by the classical community for daring to compose two full-scale operas. Now, he’s singing about the marathon of marriage (to husband Jörn Weisbrodt), being the father of a 9-year-old and the fraught relationship with his own father. “When I look at my situation of bringing up a kid on my own, it just all becomes very heightened, and a little bit dangerous,” he said, “just in terms of depression and stuff.”

His parents divorced the same year of that near-drowning, and recently Rufus and Loudon have been working hard at reconciling after years of estrangement, both “aware of this necessity to be in each other’s lives in a profound way,” Rufus said.

“We aren’t close,” Loudon admitted in an email, “but we’re working on it. It’s not easy. . . . I was an occasional father at best and there was also a great deal of acrimony between Kate and me. It lasted for decades. My father and I weren’t close either, but we wanted to be.”

“There’s a lot of information that I need from him,” Rufus said, “just about being this age, being in music, being a dad.”

It’s weird to hear this youthful gay icon — the Canadian American wunderkind who broke onto the scene in 1998 as the musical love child of Harry Nilsson and Franz Schubert, introducing an elegant style that a family friend dubbed “popera”; whose haunting cover of Cohen’s “Hallelujah” transcended its initial home on the “Shrek” soundtrack; who Elton John called “the best songwriter on the planet” — bemoaning his old age.

But Wainwright has lived a lot of life in those 47 years: surviving a rape at 14, drug addiction in the early years of his success, losing his mother to cancer in 2010. He wrestled with those demons on past albums, but somehow, he said, the regular midlife demons are more formidable.

“Pretty much all the emotions that I refer to — hatred, early morning madness, alone time, trouble in paradise,” he said, referencing song titles on the new album, “those are all things that I’m going through in my life. Having these very evident adversaries — drugs and death — made it more of a simple kind of situation, where you have to survive, and you have to mourn, all this stuff.

“Things like marriage, fatherhood, aging, yourself — those are far more daunting figures that really kind of rock your world a lot more, in a strange way. Because they aren’t as cut and dry.”

That said, “Unfollow the Rules,” out July 10, is not a sad album. Partly influenced by the 1960s Laurel Canyon scene — Wainwright lives right down the road, and often hangs out with friends in Mama Cass Elliot’s old house — it’s full of up-tempo singalongs, cheeky humor and even a pulsating electronica banger.

For the new record, Wainwright borrowed Mitchell Froom, the longtime producer for Randy Newman — another incisive singer-songwriter with a penchant for lush, movie score orchestration with whom Wainwright has often been compared.

Wainwright sent a batch of demos to Froom a few years ago, having banked a bevy of new songs since his last studio album in 2012. (In fact, the song “Unfollow the Rules” first appeared in the 2018 drama “Here and Now,” sung by Sarah Jessica Parker, who asked Wainwright if he had any unreleased tracks.) Froom identified his role as bringing clarity and simplicity to the unconventional structure of Wainwright’s songs, and really highlighting his mature, rafter-filling voice.

“You have some of the more elaborately written songs, ‘Romantical Man,’ or things that might have five or six sections in it, but you want a band to play it,” Froom said. “You have to identify the peaks and valleys, and not look at it in a traditional pop way, where it’s just beating all the way through. It has to be looked at more in a theatrical way, or a longer-form way, and then trying to maximize that for emotional impact.”

At the start of his career, Wainwright smuggled his love of opera into poppy songs. Then came more elaborate, ornate nods, like the avant-symphonic “Agnus Dei” from his fourth album, “Want Two.” All the while, he still tried to make songs that would rock or dance. “You can hear I’m trying to relate to the kids,” he joked. “But it always kind of becomes a Rufus world.”

In 2010 he released an album that included Shakespeare sonnets sung over solo piano, and then he actually went for it in 2015 with “Prima Donna,” a troubled production that was co-commissioned by the Metropolitan Opera of New York but ended up in Manchester, England. The opera, which featured a French libretto, was met coldly by the classical guard — “The overloaded orchestral textures, containing everything from Wagner to Weill, churn away below, oblivious to what the vocal lines imply,” wrote the Guardian — and some of Wainwright’s pop fans threw in the towel.

“There is a section of my fan base that has been very, very patient,” he said, but “the ones who were like, ‘Oh, he’s lost the plot, he’s become totally dull and classical and weird and I don’t get it’ . . . those ones I just don’t really care about at all.”

In the new song “Romantical Man,” Wainwright sings: “The classical critics can’t stand a melody / I only ask, what brought you to the opera firstly?” That experience was one of the great tribulations of his life, he said, but he wouldn’t trade it “for a billion dollars.”

“At the time, I was completely horrified, and wounded. Thankfully, due to those slings and arrows, I really had to figure out what the hell I was doing, you know, and why I was there, and did I really love this, or was this like a vanity thing? And just kind of soldier on. It definitely toughened me up.”

Martha Wainwright, who sings on the new album, said her brother “believes that he could be a pop star, and he believes that he should be in classical music. . . . With that belief, though, comes disappointment sometimes, but it also propels him further, much further than he maybe even realizes. . . . He’s made no artistic sacrifices, as far as I can tell.”

And Wainwright’s singing voice, according to many in his circle, is the best it’s ever been. After hearing him in January at an intimate concert at McCabe’s Guitar Shop in Santa Monica, Calif., Dale Franzen, the Tony-winning producer of “Hadestown,” told me: “There are singers you go to hear and you don’t care what they sing. I would go hear him sing anything. They say that for classical singers, the 40s and 50s are the best. There’s kind of a mastery to everything.”

Franzen compared him to the great interpreters of all time, singers like Maria Callas and Judy Garland. Wainwright said he began taking his voice — breath control, stamina, phrasing delivery — much more seriously after he recorded the Grammy-nominated live album “Rufus Does Judy at Carnegie Hall” in 2007, a tribute to his idol.

“There’s a quality in his voice, like Judy’s, that just touches the heart, doesn’t it?” said his friend Renée Zellweger, who won an Academy Award earlier this year for playing Garland in the film “Judy” and duetted with Wainwright on the soundtrack album. “It’s one thing to sing a song beautifully, and it’s another to make the listener feel the intent of the music. And he does that so brilliantly.”

The show at McCabe’s was one of three during which Wainwright performed mostly covers, which he recorded for another upcoming project, this time for Audible. “Road Trip Elegies: Montreal to New York ” is an audio journey through his past, combining a selection of music that has inspired him and an actual road trip he took with his therapist in October.

Wainwright thought that their hours of recorded conversation would go into familiar wounds like his parents’ divorce, but they ended up drifting down unexpected avenues — like thinking about his grandparents “and this generational saga that has been very exposed over the years.”

His paternal grandfather, Loudon Wainwright Jr., was a columnist for Life magazine. In his 2018 Netflix theater show, “Surviving Twin,” Wainwright III performs some of those columns, and ties one of them to his relationship with Rufus.

“On the basis of the way things are with my children,” Rufus’s father said, reading the words of his grandfather, “I doubt that the length of the acquaintance necessarily makes it easier for loved ones to know you better — or for you to know them. The past keeps getting in the way. But change is possible, and I’d like to begin work on some sort of updated realigned model for our connection, something that reflects not so much what we all were, or think we were, but what we have become.”