Former Mayor of New York Rudy Giuliani speaks during a...

Former Mayor of New York Rudy Giuliani speaks during a news conference at the Republican National Committee headquarters on Nov. 19, 2020. Credit: AP/Jacquelyn Martin

Less than 24 hours after entering Georgetown University Hospital last weekend with coronavirus symptoms, Rudy Giuliani was back on Twitter. "A MUST WATCH — VIDEO EVIDENCE FROM GEORGIA!" he wrote, heralding yet one more smoking gun to help revive his collapsing campaign to overturn the presidential election results. It was a stark illustration of Giuliani's devotion to President Donald Trump that he would tweet on the president's behalf while in a hospital bed. Even his illness was arguably Trump's fault — he has disparaged masks almost as much as the president has, and he spent much of the previous week working without one.

The former mayor's humiliations in service of Trump have been piling up. He has become a punchline, captured in a bedroom with a young woman in a movie; staging a news conference at the wrong Four Seasons; dripping hair dye and introducing a stream of cartoon characters as witnesses in a political conspiracy case that the courts aren't buying. His credibility is dissolving, one disaster at a time.

Why is Giuliani willing to destroy his reputation for Trump? Why is he apparently willing to die for Trump? For that matter, why is Trump still holding on to Giuliani, who has been embarrassing him on a near daily basis since he hired him?

On one level the answer is self-evident: The two are trapped on a sinking lifeboat and scrambling to save themselves in their waning days of power. How they ended up there is less evident, but it can be found in the underpinnings of their alliance. Giuliani, once the straight-arrow prosecutor who always played by the rules, and Trump, the real estate huckster who never did, are more alike in key ways than they at first seemed — and they respect most in each other what others cringe at or even find criminal.

The origins of this "bromance" can be traced back long before Trump arrived in Washington.

It has been 37 years since Giuliani made his first of many public splashes. Millions of Americans are too young to remember him back then, but Trump is not. His was a movie hero's story (and movies were made about it). History has cast a more skeptical eye on Giuliani's actions, but at the time he seemed as dynamic as any figure in American life. His victorious crusade to put the Commission — leaders of all five mafia families — behind bars was almost unimaginable in its audacity. (Others felt the audacious part was how much credit he took for the case.) His prosecution of Ivan Boesky, Michael Milken and other Wall Street titans captivated the nation. He seemed fearless, incorruptible, pure. "America's greatest crime-fighter," President George H.W. Bush called Giuliani in 1989, comparing him to Teddy Roosevelt, Thomas Dewey, Fiorello LaGuardia and Eliot Ness.

But he was also hailed as a champion of his city, a brilliant prosecutor who was a hardscrabble Brooklynite at heart, a member of a family that included both cops and mobsters. To Trump, another outer-borough tough guy with Manhattan aspirations, he was a kindred spirit.

Giuliani would move on to an equally epic role as mayor of New York that may well have been a template for Trump's presidency. Succeeding the genteel David Dinkins, who left office in 1993 with the streets in disarray and the government hemorrhaging billions of dollars in deficits, Giuliani was Dinkins' temperamental opposite, virtually grabbing an unruly city by the throat and forcing it to cry uncle. He was a municipal tyrant, lacerating his opponents as "jerks," bullying school chancellors, police commissioners and a long list of public officials and business leaders into submission. He was a "human hand grenade," an editorial in the New York Times said in 1998, two decades before John Bolton would use the same words to describe him during the Ukraine scandal. The Times endorsed Giuliani for reelection in 1997, comparing his temperament to "nuclear fission" and hailing him for turning the city around and reshaping its future. Four years later, on Sept. 11, 2001, his leadership made him internationally celebrated.

Trump watched mostly from a distance at the time, but the impression Giuliani made on him was consequential. Decades later, he speaks about him with unusual deference, venerating Giuliani's leadership in New York at almost every opportunity ("by far the greatest mayor in the history of NYC . . ." Trump's tweet announcing Giuliani's coronavirus diagnosis began). Giuliani's take-no-prisoners approach as mayor made a profound impact on his fellow New Yorkers, and he may have been a role model for Trump, who assumed the presidency with little knowledge of government beyond what he read in the New York Post each day.

Giuliani's mania for success, fierce intelligence and unusual passion for risk led him to score the kind of accomplishments that most elected officials can only dream about. But he is a dark, often bizarre figure who subsists on conflict and melodrama, and his personal and political decisions can range from baffling to stupendously bad. By 2016, he had suffered grievously from such poor choices. He flamed out as a presidential candidate in 2008 with a series of political miscalculations, then inexplicably forfeited the Godlike stature he'd acquired after 9/11 with snarling personal attacks on Barack Obama and Hillary Clinton, and rabid performances at Republican conventions. Seduced by the financial rewards of his fame, he made tens of millions advising a long list of dictators and other shadowy figures. His behavior left him out of his party's mainstream, so when Trump came calling, Giuliani jumped.

Since then, he has arguably done more damage to Trump's presidency than anyone aside from the president himself. He was the driving force behind the Ukraine scandal, which led to Trump's impeachment. His erratic television appearances during the Mueller investigation sparked ridicule. It was Giuliani and former New Jersey governor Chris Christie who prepped Trump before his disastrous first presidential debate against Joe Biden. Giuliani's risible efforts to prove electoral fraud have gone nowhere in court or state legislatures, and have earned him mockery for their amateurishness.

Yet Giuliani has survived while a legion of other Trump advisers have long since been pushed overboard. Aides say the president considers him a peer. He and Trump share a bond that the president will not break, regardless of how much havoc his lawyer causes him. The two men are conspiracy theorists, and wind one another up over stories about missing servers, manipulated voting machines and secret payoffs to Biden. Both see their adversaries as enemies. Both favor scorched-earth tactics against critics. Giuliani is the smarter and more strategic of the two; Trump has more common sense and better instincts.

But one is the boss and the other is his employee, and so Giuliani has trudged on in his dismal fight to overturn the election, fighting a losing battle for Trump at the expense of his own legacy.

Giuliani was 39 when he became a celebrated U.S. attorney. He is now 76, and his efforts to play the hero prosecutor's role one last time have evoked a poignant desperation. His team's lawsuits in Pennsylvania, Arizona and other states have been thrown out by a multitude of incredulous judges ("stitched together like Frankenstein's monster," wrote U.S. District Judge Matthew W. Brann of the team's Pennsylvania suit). Giuliani's "witnesses" to election fraud have become Internet memes and "SNL" fodder. His screw-ups and lies have made him a punching bag for late-night hosts. "Jared Kushner wanted a 'James Baker-like' figure," the New Yorker wrote in November, "but he ended up with a ragtag bunch of lawyers led by a raving Rudolph Giuliani." That's a common sentiment in Washington these days, and it must sting. At another point in his career, Giuliani's entrance into a case like this would have been seen as James Baker-like.

But if Washington is laughing at Giuliani, Trump doesn't seem to be in on the joke. Perhaps he respects him too much for his long-ago exploits. Or maybe it's because Giuliani is still telling his boss what he wants to hear: that President-elect Biden stole the election from him, and that the battle to upend the results is still winnable. The number of presidential lawyers willing to utter that delusion publicly or privately has dwindled to a tiny handful led by Giuliani, and Trump is an enthusiastic audience.

Giuliani certainly has reason to stay on Trump's good side. Having played his cards badly over the years and now in the twilight of his epic career, he has watched his preternatural need for relevance crash into his dwindling options. His business fortunes, speaking fees, relevance to the media — even his potential escape from prosecution — are at Trump's mercy. It's a precarious place to be, and a humbling comedown.

The president's lawyer has reportedly requested a $20,000 per day fee for his work, but that isn't the most lucrative reward Trump has to offer. The same U.S. attorney's office Giuliani once led is investigating his morass of foreign dealings, trying to determine whether Giuliani and the various shadowy foreign characters he has aligned himself with have broken lobbying laws. Trump is dangling a preemptive pardon that would end Giuliani's nightmare before it begins (he denies he has requested one but has not said whether he would accept it).

Potential indictments aside, Giuliani's power is slipping away as Inauguration Day nears. His clients, foreign and otherwise, will have far less use for his services when the White House doors slam shut. With his reputation tarnished by his public behavior and his utility to his party degraded by his over-the-top defense of Trump, his only path forward is with the Trump diaspora, where the base still views Giuliani as the sheriff of Wall Street and the hero of 9/11. Regardless of what the president does next, he will always need people to defend him.

The political world now awaits Trump's post-White House moves with curiosity and trepidation. With few options open for a next act of his own, Giuliani won't be far behind.

Kirtzman, author of "Rudy Giuliani: Emperor of the City," is working on his second book about Giuliani. This piece was written for The Washington Post.