‘Our glorious political history abounds with payoffs, bribes and bought state legislatures,” a columnist named Rudy Giuliani once wrote in his college newspaper. New York Mayor Robert Wagner was “selfish, self-centered, power hungry.” Barry Goldwater was “an incompetend [sic], confused and sometimes idiotic man.”

The future mayor’s youthful writings revealed more than just his politics at the time. His scolding tone betrayed a confidence in his fitness to arbitrate right from wrong — a confidence that would steer him toward a stratospherically successful career and then toward its potential collapse. Giuliani’s tendency to see people as either good or evil often served him well in his crusades to destroy the mob, fight crime and rescue a crippled city from terrorists. But that same moral certitude has now led him, and the country, to the precipice of disaster. How could the “Sheriff of Wall Street,” a fearsome champion of principle, end up in the embrace of a swarm of shadowy bad guys and a brazenly dishonest president?

A man who once considered entering the priesthood, Giuliani didn’t fight battles as much as launch moral crusades. He first became famous as a heroic U.S. attorney, decapitating the leadership of New York’s mob families, locking up Wall Street’s insider traders and exposing corruption in city government. “I don’t think there’s anybody much worse than a public official who sells his office, except maybe for a murderer,” the prosecutor said in 1987. Later, as a transformative, if divisive, mayor of New York, he held that the city’s inhabitants had a right to safe, hassle-free streets, his justification for his police department’s policy of indiscriminately frisking young, low-income men of color. Zero tolerance wasn’t just a policy — it was his view of the world.

I was a political reporter for NY1, the city’s all-news television channel, when the planes struck the World Trade Center on Sept. 11, 2001. My boss sent me to find the mayor, and I located Giuliani standing on a street corner with a clutch of aides three blocks from the twin towers, one of which had just imploded. They were covered in ash. He waved me over, and we trekked as a group in search of shelter. In that journey up Church Street, I witnessed an act of leadership unlike anything I had ever seen in an elected official. When the second tower collapsed behind us in a thunderous explosion, we bolted up the street, trying to outrun a mushroom cloud chasing us north. I was covered in sweat and feeling more than a little shaken. Giuliani, one of the most hot-tempered figures I’d ever covered, was noticeably calm. He proceeded to game out the situation with the commissioners and advisers walking alongside him, beginning his long, methodical effort to bring the anarchy under control. More than anything else, he telegraphed the message that there was no reason to be afraid, because he knew the right things to do.

In the days that followed, the public saw a born leader rising to the challenge of a terrifying situation. The city was under virtual lockdown, air travel was suspended, and thousands of people were searching desperately for missing family members. While the politicians who would join up with him offered useless platitudes about America’s greatness, Giuliani provided a candid running narrative of the efforts to find survivors, reestablish vital services and reopen institutions. He exuded calm, competence and compassion. His stature grew by the hour. In the following weeks and months, he was proclaimed a hero by heads of state, bestowed an honorary knighthood by the Queen of England, invited to address the United Nations General Assembly and named Time’s Person of the Year. He became a best-selling author and a political superstar. For years to come, he could barely walk into a New York restaurant without receiving a standing ovation. The universe had blessed him with validation.

The opportunities available to him were limitless. He could have followed the path of a war hero, assuming the presidency of a university, becoming the chairman of a corporation or perhaps forming a think tank dedicated to fighting terrorism. Or he could have run for office as a statesman, eschewing ideology for the higher principle of public service.

But because he was prone to framing his decisions in the starkest terms, he instead found his calling speaking out against the dangers of weak leadership and moral relativism in the age of Islamic terrorism. “There’s no moral way to sympathize with grossly immoral actions,” he argued in his U.N. speech, three weeks after the attacks. “We are right and they are wrong.” With that, he threw his lot in with George W. Bush, Dick Cheney, the war on terrorism and the invasion of Iraq.

His politics headed increasingly rightward. Much of what Giuliani defined as moral struck others as deeply immoral. In the years after his Sept. 11 leadership triumph, his security consulting firm made millions from a succession of questionable clients, such as Purdue Pharma, the maker of OxyContin. But few were up to denying “America’s Mayor” the right to enjoy the fruits of his success.

In 2008, he entered the race for president and was instantly the front-runner in the Republican primary contest, thanks to his sky-high name recognition. But it was an iffy proposition because of his pro-choice politics and his highly publicized marital infidelities. His strategy for maneuvering around those liabilities by skipping the first five contests and waiting for the Florida primary proved disastrous. In basing his candidacy around terrorism and Islamic fundamentalism, he wildly overplayed the 9/11 card, leading Joe Biden to famously quip that all of Giuliani’s sentences relied on “a noun and a verb and 9/11.” In the end, he earned just a single delegate.

His rightward turn fundamentally changed his relationship with a public that had viewed him as a statesman. The applause died down, his security business dwindled as the 9/11 luster faded, and, according to his soon-to-be-ex-wife, Judith Nathan, he fell into a deep depression. Giuliani faced a question only a handful of people in history have had to confront: What happens when you’re beloved across the world — and then you’re not?

Slowly, Giuliani’s cocksure politics took on an angrier tone. He sought refuge in the friendly confines of Fox News Channel, whose viewers continued to revere him, and launched salvos at President Barack Obama, whom he disdained as a dithering liberal reluctant to call right from wrong. “I do not believe that the president loves America,” he told a gathering in 2015. Freed from the glare of the political press, he also focused on an international client roster that included autocrats, strongmen and assorted international men of mystery. He signed on as an “economic development advisor” to Aleksandar Vucic, a candidate for mayor of Belgrade who had once, as Slobodan Milosevic’s information minister, authored a law banning criticism of the Serbian government. He also engaged with Keiko Fujimori, a Peruvian presidential candidate and daughter of Alberto Fujimori, a former president serving time for murder and kidnapping.

Giuliani may one day explain why he felt it was appropriate to work for Ukrainian oligarchs, Turkish gold traders and Romanian real estate tycoons, many of whom he still represents even while he serves as President Trump’s personal attorney. The obvious explanation is that they paid well; he earned tens of millions of dollars by leveraging his Rolodex and good name. But I suspect that he also felt morally justified in representing each and every one of them. Today, even as he hangs from a legal and political precipice because of the scheme he ran to enlist Ukraine’s help in reelecting Trump, he hasn’t betrayed a whisper of doubt about the clients he chose. His moral certitude has never diminished.

The brazenness of this work, with all its conflicts and disregard for U.S. national interests, seems surprising. But it is in keeping with a lifelong pattern. If he thinks he’s right, he’ll boast about it unapologetically, regardless of the consequences. Most famously, as mayor, he announced his relationship with Nathan on live television while still married to Donna Hanover, then proceeded to appear in public with Nathan in the months that followed.

Giuliani is now in deep trouble, but he’s so confident of the appropriateness of his actions in Ukraine that he has spent weeks telling television news hosts and print reporters many of the details that now form the basis of the impeachment inquiry. When you know you’re right, what’s the harm?

Twitter: @andrewkirtzman