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.”