The closet that Pete Buttigieg built for himself in the late 1990s and 2000s was a lot like the ones that other gay men of his age and ambition hid inside. He dated women, deepened his voice and furtively looked at MySpace and Friendster profiles of guys who had come out all while wondering when it might be safe for him to do so too.
Chris Pappas, who was two years ahead of Mr. Buttigieg at Harvard and is now a Democratic congressman from New Hampshire, said he arrived at college pretty much convinced that I couldnt have a career or pursue politics as an L.G.B.T. individual. Jonathan Darman, who was one class ahead of Mr. Buttigieg, remembered how people often reacted to a politicians coming out then: It wasnt a story of love but of acknowledging illicit desire. And Amit Paley, who graduated in Mr. Buttigiegs class, recalled that it was still a time where vocalizing anti-gay sentiments was not only common, but I think pretty accepted.
The thought that 15 years later someone they might have shared a dorm or sat in a lecture hall with would become the first serious openly gay candidate for president of the United States never crossed their minds. But no one would have found the possibility more implausible than the young man everyone on campus knew as Peter.
Mr. Buttigieg, now the mayor of South Bend, Ind., struggled for a decade after leaving Harvard to overcome the fear that being gay was a career death sentence, as he put it in his memoir.
Many in his generation and in his college class decided to come out as young adults, whether they were confident they would be accepted or not, and had their 20s to navigate being open about their identity a process that helped make Americans more aware and accepting of their gay friends, family members and co-workers. Instead, Mr. Buttigieg spent those years trying to reconcile his private life with his aspirations for a high-profile career in public service.
Attitudes toward gay rights changed immensely during that period, though he acknowledges that he was not always able or willing to see what broader social and legal shifts meant for him personally.
Because I was wrestling with this, Im not sure I fully processed the idea that it related to me, he said in an interview.
More than most people his age even more than most of the ambitious young men and women he competed against at Harvard he possessed a remarkably strong drive for perfection. He went on to become a Rhodes scholar, work on a presidential campaign, join the military and be elected mayor all before he turned 30. After being deployed with the Navy to Afghanistan in 2014, he said he realized he could die having never been in love, and he resolved to change that. He finally came out in 2015, when he was 33.
He took a longer journey than his peers did, he has said, because of the inner turmoil he experienced over whether in fact he wanted to be known as the gay politician.
His record of accomplishment during those years in the closet is impossible to separate from the isolation and anxiety he felt as he weighed the cost of telling his family, friends and constituents who he really was. Pursuing so many goals had two outcomes, intentionally or not: It distracted his busy brain from a reality he wasnt ready to face, and provided him the armor of a life experience that would make his sexual orientation just one of a litany of attributes.
Peter struck me very early on, at 18 or 19, as someone who would run for president regardless, said Randall Winston, a close friend of Mr. Buttigiegs from college. Over beers and Chinese food, Mr. Winston said, they spent late nights on campus talking about the right and wrong reasons for getting into politics. If you want to be a political leader, why? he recalled. Is it about yourself? Is it really about the good of the nation? I think he was asking himself those questions from the jump.
Mr. Buttigieg said in the interview that if he had been interested in a career other than politics, he would have found the decision to come out much easier. The arts is one where you could have jumped in there in the 2000s, and it would have been sort of incidental, he said. Whereas something like finance, it was getting there. And in politics it would have been completely defining.
Few experiences in his young adulthood were as formative in shaping his identity as the hypercompetitive environment he encountered at Harvard. Even liberal Cambridge, where meeting a gay student or professor would have been fairly unremarkable, did not always nurture the sense of confidence that he and many of his gay classmates felt they needed to be themselves. At times their surroundings seemed to do just the opposite.
In interviews with a dozen of Mr. Buttigiegs friends and classmates, people described a culture in which a mix of abundant ambition and youthful insecurity made students carefully attuned to the way they presented themselves to others.
Mr. Winston recalled the dual pressures of having high expectations for yourself while also being aware sometimes realistically, sometimes not that your classmates and professors had their own ideas about who you were too.
I dont want to say its all artifice a lot of this is just common to growing up, he said. But the culture at Harvard, he added, caused a lot of students to think, O.K., Im going to maintain this aura, this impression Im giving to others.
Describing the insecurities he felt as a young man, Mr. Buttigieg has said he sometimes marvels at how differently the world treats him today compared with what he expected when he was too afraid to come out. On the day he kicked off his presidential campaign, he said he had imagined what he would say to his teenage self. To tell him that on that day he announces his campaign for president, hell do it with his husband looking on, he said with a note of disbelief in his voice. Would he believe me?
Mr. Buttigieg took a long and fraught path from life as an undergraduate who once had a girlfriend to a presidential candidate who travels the country with his husband in tow. While he was still in the closet, the country became a different place very quickly. And to understand Mr. Buttigiegs journey is to understand the microgeneration in which he came of age.
When members of the Harvard class of 2004 were juniors in high school, Matthew Shepard, a 21-year-old gay man from Wyoming, was bludgeoned, tied to a fence post and left to die in a murder that shocked the nations conscience. By the time they shipped off to Cambridge, few would have any gay friends at least ones who were open about it. And the idea of a man marrying another man, or a woman marrying another woman, seemed almost absurd. The closest thing gay men and lesbians had to marriage was a civil union, which in 2000 was legal in exactly one state: Vermont.
Gay marriage was not this obvious liberal no-brainer, said Mr. Darman, a journalist and historian who came out in his senior year of college, 12 years before Mr. Buttigieg would. While Harvard was certainly a liberal bubble, it was still in many ways very socially conventional in the early 2000s, he said. In a lot of social settings at Harvard in that period, the default assumption was that you were straight. And that would not have been true even five years later.
Friends and classmates remembered Mr. Buttigieg as thoughtful and clearly on a trajectory that would bring him success of some kind, even if it dawned on few of them that might mean the White House.
One thing no one seemed to peg him for was someone wrestling with being gay. He was so discreet that many of his friends and classmates said in interviews that they never would have guessed he was hiding anything until he told them. He left the testosterone-fueled campus sex banter to others. Hegel and de Tocqueville were more to his conversational tastes.
His sexuality didnt present as a really big thing in his life, said Joe Flood, a classmate. I think he always thought about himself politically, he added, noting that Mr. Buttigieg would become active in the universitys Institute of Politics, an organization at the Kennedy School of Government that hosted big-name politicians like Senator Edward M. Kennedy and Howard Dean during their time in school. You dont end up there accidentally, Mr. Flood said.
By the beginning of his sophomore year, Mr. Buttigieg had been elected to lead one of the institutes committees. When he was a junior, he was elected as its president. His platform, in part, called for strengthening the community of politically minded students by having gatherings to watch The West Wing. He wrote for The Crimson under the byline Peter P.M. Buttigieg and covered subjects as disparate as Dave Matthews and Yeats. For fun, he and his friends sometimes indulged themselves with less-than-puerile pursuits like a day trip to the birthplace of John Adams.
There was a small, close-knit social circle of L.G.B.T.Q. students. But they existed a world apart from Mr. Buttigiegs Harvard.
We were definitely on opposite ends of the gay spectrum he was closeted and I was literally the campus drag queen, Miss Harvard 2002, said William Lee Adams, who graduated in Mr. Buttigiegs class and is now a broadcaster at the BBC World Service in London. Mr. Adams started coming out at age 12. Arriving at Harvard from his home in Georgia, he said, was like fleeing the desert. The two were not friends, though Mr. Adams did recall his classmate as sweet but rather serious.
At the time, Mr. Adams said he was somewhat resentful of his peers who kept their identities hidden, having been bullied at school while he was growing up. Now, however, he is far more sympathetic because he better understands how personal it is to come out. I felt a great sense of freedom at Harvard that I had never felt before because I could be out and not have food thrown at me, he said. Whereas Pete must have felt trapped, like he was in a straitjacket.
Mr. Flood, who wrote for The Crimson and knew Mr. Buttigieg as a friend, said that someone who worked so hard and thought so intensely about his future had to feel frustrated as he realized there was this immutable aspect of his life he was helpless to change.
Its like the one thing he couldnt control about who he was and how he was going to present and how he was going to do all these things, he said.
But when Mr. Buttigieg and his peers left college and started embarking on their professional lives, the country was changing in significant ways, jolting their sense of what it could mean to be openly gay and have a high-profile career.
One of the biggest developments was right in Harvards backyard. In 2004, Massachusetts became the first state where same-sex couples could marry. Students flocked to Cambridge City Hall in the early-morning hours on May 17 to watch the first couples wed at 12:01 a.m. the earliest moment possible under the new law. Mr. Buttigieg remembers the occasion but was not there. I dont remember feeling that connected to it actually, he said.
Soon states from Iowa to Maine would start allowing same-sex couples to marry. Then Congress would repeal the militarys dont ask, dont tell ban on serving openly as gay or lesbian. And the Supreme Court would declare the rights of gay men and lesbians to have their relationships recognized by the state, first in 2013 when it struck down the Defense of Marriage Act in United States v. Windsor, and then again in the 2015 decision that guaranteed same-sex marriage as a right protected by the Constitution in Obergefell v. Hodges.
In 2004, when Mr. Buttigiegs class graduated, public opinion polls showed that roughly one-third of Americans favored allowing same-sex couples to marry. A decade later it was more than half the country and rising.
Many closeted people found their plight more difficult during the early years of social and legal change, as they wrestled with whether to finally open up after years of trying to maintain an impression of themselves that was false.
Mr. Paley, who was Mr. Buttigiegs college classmate, remembers sitting in his dorm room in 2003 as a closeted junior and crying as he read Justice Anthony M. Kennedys opinion in the landmark case Lawrence v. Texas, which struck down bans on intimacy between homosexuals on grounds that such laws were an affront to their dignity. That helped me realize I cant live my life this way, he said of hiding his sexual orientation. It took Mr. Paley until the end of his senior year to fully come out, and he now serves as chief executive of the Trevor Project, an organization that works to advance the rights of L.G.B.T.Q. youth.
Mr. Pappas, the congressman from New Hampshire, ran his first race for state legislature in 2002 as an openly gay candidate and won. Its an important facet of who I am, he said. And I think over time I realized how powerful it was that I share that with more and more people.
He said he ran as an out candidate in that first race because he saw no point in turning back after he came out in college. And after hearing from people who told him how encouraging it was to see him as an openly gay man in politics, Mr. Pappas realized he had made the right choice regardless of the political implications. I dont think I fully appreciated that at first, he said.
After he graduated, Mr. Buttigieg went to work for John Kerrys presidential campaign in Arizona and quickly immersed himself in the job. Mara Lee, who worked with him at the time and remains a friend, remembered meeting her co-worker for the first time: Heres this guy whos doing a million things at once. He has seven or eight TVs on to monitor the local and national news. Hes introducing himself to me being genuine and having a conversation while typing. She remembers two computer screens on his desk.
Once he came out, she said that being gay was never the first thing he wanted people to see when they met him a veteran, Rhodes scholar, polyglot who was first elected mayor of South Bend when he was 29. While its an important part of who he is, its not the only part, she said.
When he first ran for mayor in 2011 and won, he was closeted. A local gay rights group did not initially endorse him in that race, opting instead for a candidate with a more established track record on the issues. Mr. Buttigieg endured some awkward moments, like signing a city law banning discrimination based on sexual orientation in 2012. To not think about how the law directly affected him, he acknowledged, took a little compartmentalization.
His employees and constituents saw an eligible bachelor in their young mayor and wanted to set him up with their daughters. Some on his staff even joked about his old light green Ford Taurus as a chick magnet. He did not bother to correct them.
When he did come out in the summer of 2015, the forum he chose was an op-ed for The South Bend Tribune. It took years of struggle and growth for me to recognize that its just a fact of life, like having brown hair, and part of who I am, he wrote.
He may have waited far longer than most young gay men today. But ever the overachiever, he made record time in setting a new bar. In less than four years he went from being single and closeted to being married and out as a gay candidate for president.