After attending rehab, the swimmer is not fixated on adding to his record total of Olympic medals in Rio. The journey now is personal.

COLORADO SPRINGS — The guide enthusiastically led his guest from room to room in the barracks-style building, pointing out features like the emotion tree and providing thumbnail sketches of the people they encountered. He seemed to know everyone, and everyone returned his greetings in kind with a comment that elicited the guide’s generous, rumbling laugh.

The tour ended in a television room, where the guest and the guide watched an Arizona Cardinals football game while grazing on snacks. For years, the guide, Michael Phelps, and his guest, Bob Bowman, had watched N.F.L. games together, but from a suite above the Baltimore Ravens’ home field at M&T Bank Stadium, sealed off from autograph- and selfie-seeking strangers but often surrounded by “friends” who fed off Phelps’s swimming fame.

The trip to see Phelps by Bowman, his longtime coach, at the Meadows, a treatment center in Wickenburg, Ariz., northwest of Phoenix, in the fall of 2014 was a revelation, an introduction to a man stripped of the armor that had helped make him an athletic machine.

Bowman had difficulty reconciling the swimmer who wore headphones to the starting blocks to sequester himself from the outside world, the guy who was so deeply absorbed in his own journey that he did not learn the given names of all of his teammates on the 2004 and 2008 United States Olympic swimming squads, with the person standing before him offering biographical snippets on those who walked past.

“He was like, ‘That guy over there, he owns his own company,’ ” Bowman said. “He had a little story about everybody. I had never seen him like that. I looked at him like ‘Who are you?’ ”

It is among the questions Phelps, 30, sought answers to in rehab and, in some ways, is still answering as he seeks to make it to his fifth consecutive Olympics at the United States swimming trials, which begin Sunday.

Phelps’s road to becoming the most decorated athlete in Olympic history had been treacherously steep and single-file narrow, as isolating as a deep free diver’s plunge. The years he should have spent developing and embracing his personality were devoted to developing and embracing his swimming talents.

Michael Phelps won a gold medal as part of the United States’ men’s 4x100-meter medley relay team at the 2008 Beijing Olympics, where he captured eight golds.

It seemed like a path well chosen when Phelps won a record eight individual gold medals at the 2008 Summer Olympics in Beijing. The years that followed produced more Olympic glory but also a damning photograph of Phelps with a bong, a second D.U.I. arrest and numerous splintered relationships.

By the end of 2014, it appeared plain to everyone that the trail Phelps blazed had veered into a dead end.

“He had no idea what to do with the rest of his life,” Bowman said. “It made me feel terrible. I remember one day I said: ‘Michael, you have all the money that anybody your age could ever want or need; you have a profound influence in the world; you have free time — and you’re the most miserable person I know. What’s up with that?’ ”

Phelps has spent the past year and a half pondering it first in therapy as an inpatient at the Meadows and later in the pool, which started out as his sanctuary, became his glassed-in aquarium and now serves as his platform. His message: Vulnerability is a strength.

A plaque outside the natatorium at the United States Olympic Training Center here in Colorado Springs, where Phelps spent several weeks in the spring, hails him as “the most successful Olympian in history with 14 total gold medals,” as if Phelps’s story culminated with the 2008 Olympics. Phelps won six more medals, including four golds, at the London Games four years later, but in a way his narrative — at least the one worthy of proclaiming — did end in Beijing.

When Phelps looks at his legacy post-Beijing, all he sees is the tarnish. He has spent the past two years applying elbow grease in the hope of burnishing it. He said he was training as well as he ever had, but his focus was no longer on adding to his record haul of medals: the 18 golds, two silvers and two bronzes.

This time, the journey is more personal. He said he was on a quest to leave the sport without remorse over the poor training and worse behavior that defined his pre- and post-2012 Olympic experience. “This time, it’s about trying my hardest, giving it my all,” he said. “I don’t want to live the rest of my life with any regrets.”

The journey to Rio de Janeiro started with a six-week stay at the treatment center, about an hour’s drive from where he has spent the past year training under Bowman, who took over as coach of the Arizona State men’s and women’s swimming teams in 2015. Bowman had been firmly against Phelps’s entering the Meadows after his second D.U.I. arrest in September 2014 (his first occurred when he was 19).

The Meadows, a treatment center in Arizona, where Michael Phelps had a six-week stay in the fall of 2014 after a D.U.I. arrest.

“I thought he was going someplace in Malibu to sit on the beach for six weeks and he would come out the same,” Bowman said.

But then he watched Phelps interact with his fellow patients during the fourth week of his six-week stay and saw the kind, caring young man he remembered before his sharpening turned him into a high-performance machine.

At the Olympic Training Center cafeteria in late April, Bowman became emotional when he said, “I never thought that he would ever change.” He added: “He hid everything that makes him human for 12 years. The rehab is what opened him up.”

Hitting Bottom

Phelps, once known for his prodigious appetite, has scaled back his calorie intake; that and increasing his postswim ice baths are about the only concessions he has made to age. Phelps, who turns 31 on the fifth day of the trials, said he felt physically stronger in the water, perhaps because of drills Bowman added to his pool workouts, like multiple repeats of 40 seconds of dolphin kicking while hugging a 10-pound weight to his chest.

In the cafeteria, Phelps placed on his tray a three-egg omelet, three blueberry pancakes slathered in butter and syrup, and a parfait cup of plain yogurt topped with blueberries and strawberries. As he talked, he cut his pancakes with a knife with the meticulousness of a surgeon. It is one of his habits. Others include warming up in the same lane every day of a meet and lining up the food in his refrigerator with the fastidiousness of a drill sergeant at a parade.

A television bolted to a nearby wall was tuned to ESPN. Phelps glanced at the screen in time to see an image of the former Cleveland Browns quarterback Johnny Manziel, who was in the news after being accused of assaulting a former girlfriend and for excessive drinking and partying.

“I think Johnny Manziel is taking it to a new level right now,” Phelps said. “It’s really sad.”

Phelps with his coach, Bob Bowman, at a meet this month in Texas. “I never thought that he would ever change,” Bowman said, adding: “He hid everything that makes him human for 12 years. The rehab is what opened him up.”

Phelps’s nadir came two years ago, on the last Monday of September. On his way out of the Horseshoe Casino, two miles from Baltimore’s Inner Harbor, after an evening spent playing poker while drinking, Phelps placed a phone call to his girlfriend, Nicole Johnson. After a two-year estrangement, they had recently gotten back together, a reconciliation set into motion by a soul-baring call from Phelps.

It was after 1 a.m. on the East Coast. Johnson, on the West Coast, asked Phelps if he was sure he was O.K. to drive home. He had spent the start of the weekend with her in California at a wedding and had flown home on a redeye, landing in Baltimore less than 24 hours earlier.

She said she was concerned that fatigue from his hectic weekend, combined with the cross-country travel, might aggravate the effects of the alcohol in his system.

A few minutes later, she received a text from Phelps, who was stopped at a light. “There’s a cop behind me,” he said. An hour passed before her next communication from Phelps, who phoned from jail.

His Range Rover had been clocked by the police traveling 84 miles per hour in a 45 m.p.h. zone, and Phelps had been observed crossing the double lines. According to a report in The Baltimore Sun, he failed two field sobriety tests, and a breath analysis recorded his blood-alcohol level at 0.14, 0.06 in excess of the state driving limit.

For the next 72 hours, Phelps locked himself in his house and refused to see or talk to anyone. At one point, he texted his agent, Peter Carlisle, and said he wrote, “I don’t want to be alive anymore.”

The machine was irrevocably broken.

“I didn’t see me as me,” Phelps said. “I saw me as everybody else did — as an all-American kid. Let’s be honest. There’s not a single human being in the world that’s like that.”

He took the advice of his inner circle and agreed to go to the Meadows.

“I was so afraid coming in,” Phelps said. “I wasn’t ready to be vulnerable. And then, after a couple of days, I said: ‘My wall is down. Let’s get into this and see what’s going on.’ ”

Michael Phelps at the Olympic Training Center. “This time it’s about trying my hardest, giving it my all,” he said. “I don’t want to live the rest of my life with any regrets.”

Too Big to Fail

For several years, beginning in grade school, Phelps had a recurring dream about snakes. They would appear suddenly in his path, “and I would freak out,” he said. The dream started sometime after his parents divorced when he was 9.

Phelps’s father, Fred, who spent more than a quarter-century as a Maryland state trooper, was a shadowy presence in the life of his youngest child and only son. What bonding they did was through sports. His father recalled taking Phelps to Orioles home games. His law enforcement ties allowed him to gain access, with his son, to the clubhouse.

Phelps played multiple sports until he was 11, even if he started the day with a swim workout.

In 1996, Bowman, new to the North Baltimore Aquatic Club, told Phelps’s parents that their son had the potential to make the Olympics and become a “special” swimmer. But it would require sacrifices from all. They would have to make sure Phelps got to workouts in the early morning and the late afternoon, seven days a week as it turned out, and Phelps would have to give up other sports.

Michael Phelps with his father, Fred, a longtime Maryland State Trooper, in 2000. Phelps has re-established regular contact with his father since his stay at the Meadows.

Fred Phelps said he had reservations about sending his son down such a narrow path. “He never got a chance to be a teenager, like most normal kids,” he said, adding: “I’d encourage him to take the occasional break. I’d say, ‘Let’s take three or four days, go to the beach.’ And I’d get overruled.”

His parents’ divorce was hard on Phelps. He would grow upset when his father missed a swim meet or canceled a father-son outing at the last minute, summoned to work.

Phelps said he channeled his anger and disappointment into his swimming workouts. “I would use that for fuel in the pool,” he said.

In 2000, Phelps became the youngest male on the United States Olympic swim team, qualifying in the 200-meter butterfly as a 15-year-old. At the Sydney Games, with both parents in attendance, he finished fifth.

At the world championships in Barcelona, Spain, three years later, Phelps became the first man to break five individual world records in a meet. The competition foreshadowed his eight-medal haul at the next year’s Olympics, in Athens, and also the jealousy his success would engender. Bowman remembered that when Phelps walked into the dining hall after his first world-record swim, the other American swimmers showered him with hearty applause. After his second and third world-record swims, the reaction was more tepid.

By the end of the meet, Bowman said, the clapping was halfhearted. “I remember it so clearly,” Bowman said. “It was like the other swimmers were thinking, What spot of mine is he going to take in the next Olympics?”

Michael Phelps sporting the six medals he won at the world swimming championships in Barcelona, Spain, in 2003, setting some world records in the process.

The same isolation that Phelps experienced in his swimming family, he would recreate in his nuclear family. Sometime after the 2004 Olympics, father and son stopped speaking. “We’re both a little hotheaded and we react emotionally,” Phelps said. “I knew exactly how to set him off, and he was the same way with me.”

Phelps’s original goal had been to raise the profile of the sport. After his superstar turn at the 2008 Olympics, he felt trapped because of how well he had accomplished his mission. In retrospect, Bowman said, Phelps probably should have retired after the Beijing Games. But he was 23 years old, with no college degree, and several of his corporate partners, as well as swimming’s national governing body, were keen on his continuing to grace the world stage.

“We created a monster, and after Beijing it was too big to fail,” Bowman said. “We had to do whatever we could to keep it going. That’s how we got to London. The deal with his dad, how to come to grips with his fame, those kinds of things, I thought, we’ll deal with later.”

Phelps described his decline as inevitable and said: “It’s like we dreamed the biggest dream we could possibly dream and we got there. What do we do now?”

In 2009, a photograph surfaced of Phelps smoking from a marijuana pipe. The picture was taken at a small private gathering where Phelps believed he was among friends. After that, Bowman said, Phelps changed. He became warier, wearier.

Despite a general lack of interest in training, Phelps qualified for the 2012 Olympics with minimal preparation and won four golds and two silvers. He retired to the golf links, but with no structure to his days and no energy-sapping exercise to mitigate his symptoms of attention-deficit hyperactivity disorder, he acted with more impulsivity. Phelps drank alcohol, sometimes heavily, and hung out with people who enabled his sometimes reckless behavior.

Michael Phelps at a magazine party on a New York City hotel rooftop in September 2012. The years after his success in Beijing in 2008 led to more Olympic glory but also personal turmoil.

Bowman could not reach him. Neither could Phelps’s mother, Debbie. He refused to take her calls or answer the door when she made trips to his house to check on him. “I was just pushing people away,” Phelps said.

At the treatment center, he reached out to Bowman, his mother, his sisters and his father, whom he invited to a family weekend.

Upon receiving the letter of invitation, Fred Phelps almost immediately booked his travel. “That’s my baby boy,” he said, “so I was going to be there for him whether he cold-shouldered me or not.”

Since that weekend, Phelps and his father have kept in regular contact. When Phelps was on the plane traveling home from here in May for the birth of his first child, a son, Boomer, he exchanged texts with his father. Since their rapprochement, Phelps has slept better.

“It’s kind of weird,” he said. “Once my father and I started talking, I haven’t had a dream about snakes since.”

A Breakthrough

In his second week of rehab, the men’s circle he attended awarded Phelps the saguaro stick, a symbol of power passed on each week to a patient who exhibits leadership qualities. Phelps said he paraded around with it more proudly than he did any of his Olympic medals.

He began reading books, sometimes aloud in group sessions, and it has become a habit. One day, he casually mentioned to Bowman that he was reading “Man’s Search for Meaning,” by Viktor E. Frankl, a Holocaust survivor who became a psychiatrist. Bowman was shocked. He said he had seen Phelps read only magazines. As the trials drew near, Phelps ordered “The Power of Your Subconscious Mind,” by Joseph Murphy, and “The Purpose Driven Life,” by Rick Warren.

To paraphrase Warren, what on earth is Phelps here for? For starters, he said, to be Johnson’s life mate and his son’s father. To have more medals than any other Olympian? He said he no longer sees that as his sole reason for being.

Phelps was in his second week of therapy when he experienced the breakthrough that has been like a second wind propelling him forward. At lunch one day, he was his usual talkative, hyper self. After working out for two hours to expend his energy, he found himself brooding about his behavior, as he often did. “I was afraid to show who I was,” he said, “so I had all these personas.”

In the shower, he shed all his second skins. Phelps said: “I thought: Oh my God, do these people think I’m annoying? Do they not want to be around me? Then I thought, Why do I care? If I talk too much, if I laugh really loud or if I’m hyper at times, or a real pain in the ass, at the end of the day why does it really matter?

“Right then and there it was like there’s no point for me to try to be somebody I’m not. This is who I am.”