The boos cascaded from the stands, wafting over Monument Park, turning a moment of between-inning indifference at Yankee Stadium into a visceral spirit cleansing.

That it was directed toward a former mayor was no surprise; sports fans excel at heaping opprobrium on political leaders when they intrude into their temples.

But that it occurred to Rudolph W. Giuliani, on the occasion of his 74th birthday on Memorial Day, in a stadium that has long been a safe space, was different — a reflection, perhaps, of how Mr. Giuliani and the city he once led have drifted apart.

A brief video of the booing quickly made the rounds on social media, heartening many Democrats angry at Mr. Giuliani’s strenuous defense of President Trump on television.

“I used to boo him 20 years ago,” said Ruben Diaz Jr., 45, the Bronx borough president. “But if there was one place in the whole world he was popular, it was inside Yankee Stadium. Boy have times changed.”

For those old enough to remember, Mr. Giuliani once embodied a kind of holy trinity of grief, resurrection and baseball after Sept. 11, 2001. He could often be seen in his matching Yankees jacket and cap as the World Series-bound team lifted a wounded city after the terrorist attack.

Long before that, Mr. Giuliani credited his Yankees fandom with giving him strength of character from a young age: He said he had to stand up to jeers from Brooklyn Dodgers fans in his Brooklyn neighborhood.

“I kept telling them: ‘I am a Yankee fan. I am a Yankee fan. I’m gonna stay a Yankee fan,’” he said in a 1995 interview. “All of our family in that four-block area were Dodger fans, so this was a constant fight for me.”

He added that wearing the Yankees uniform in his old Brooklyn neighborhood, “to me it was like being a martyr: I’m not gonna give up my religion. You’re not gonna change me.”

He carried that through his career. He celebrated Yankees victories at City Hall, his own image blown up banner-size to hang next to those of the players and coaches. The Times, during the 2000 Subway Series with the Mets, described Mr. Giuliani as the team’s mascot, akin to Mr. Met: “The mascot for the Yankees wears a Yankees warm-up jacket and has a somewhat smaller head; his name is Mister Giuliani.”

He has bejeweled championship rings from the Yankees’ run of World Series wins during his term, prized possessions that brought scrutiny during his failed 2008 presidential bid. He worked on paving the way for a new stadium in the Bronx, negotiating into the waning days of his second and final term.

At Monday’s game, Mr. Giuliani was given a cake by Randy L. Levine, who was Mr. Giuliani’s deputy mayor for economic development and is now the president of the Yankees. “‘Happy Birthday Rudy,’” he recalled it saying. “I think it was chocolate.”

Mr. Levine told his former boss that his name would be mentioned midgame along with other fans celebrating birthdays.

“He didn’t ask for it,” Mr. Levine said.

Then came the boos.

“Honestly, if you were at the stadium and you were in the moment, there were just as many cheers as there were boos,” Mr. Levine suggested. “You could hear the boos more because they’re louder than the cheers.”

Mr. Giuliani, who was with friends and family, apparently laughed it off.

“He was with Andrew, and actually I think they videotaped it on their phones,” Mr. Levine said, speaking of Mr. Giuliani’s son, who works in the White House. “When it came up, he laughed. Because a true baseball fan knows what happens. I think Rudy has been in a lot more difficult situations than Yankee Stadium.”

Still, these were not Dodgers fans heckling him, but his own tribe.

“I don’t think it says anything about anything,” Mr. Levine said.

Mr. Giuliani did not respond to a request for an interview, but told reporters at the White House on Wednesday that he was not upset. “I know Yankee fans; they boo you when they love you,” a Fox News producer quoted him as saying.

But for younger fans, New York City is a different place from what it was when Mr. Giuliani took charge, promising to rein in lawlessness. Crime, now at historically low levels, is for many New Yorkers an afterthought.

Many residents of the majority-minority city are more likely to associate Mr. Giuliani with police brutality than with his law-and-order bona fides. The New York Police Department is now trying to put the excesses of that period behind it.

“He’s racist,” said Henry Williams, 61, a Bronx man who cleans up at Stan’s Sports Bar across the street from Yankee Stadium. “I’m still out here struggling.”

John Catsimatidis, 69, a billionaire grocery magnate, Republican donor and erstwhile mayoral hopeful, had a different view. “It’s not right,” he said of the booing. “Rudy did a great job in New York City.”

The new generation of fans, he said, may not know what the city was — and what it could become again. “I think they have to realize the dangers; the world is not nice,” he said. “If we end up with more people that are just wishy-washy, then I think our country is in danger.”

Mr. Giuliani has certainly changed over time. His marriage to Judi Nathan — his frequent companion at games — is ending; his good will here after Sept. 11 has dwindled.

Indeed, Monday was certainly not the first time Mr. Giuliani was booed by Yankees fans: He was similarly greeted in 2007 during his Republican presidential primary run when his image appeared on the big stadium screen.

But in his role as President Trump’s defender, Mr. Giuliani may have pulled the last straw.

“Why were they booing him?” Margaret Fucheck, 22, a recent graduate of the State University of New York at Cortland, asked her two friends at a Yankees game on Tuesday night. “He hasn’t done anything in a while.”

Reminded of his advocacy for the president, the three women from Westchester County exclaimed together, “Oh!”

As if to say, of course. That makes sense.

A version of this article appears in print on , on Page A20 of the New York edition with the headline: Giuliani, Booed at Yankee Stadium, Loses His Home-Field Advantage. Order Reprints | Today’s Paper | Subscribe