On Oct. 25, 2016, exactly two weeks until Election Day, Mr. Giuliani appeared on “Fox and Friends,” and was asked what the Trump campaign would do with the remaining time.

“We’ve got a couple of surprises left,” Mr. Giuliani said, chuckling but coyly refusing to be drawn out on specifics.

“I think he’s got a surprise or two that you’re going to hear about in the next few days,” he told another interviewer. “I mean, I’m talking about some pretty big surprises.”

Unknown to the public, the F.B.I. had recently obtained a laptop used by one of Mrs. Clinton’s aides that had not been examined during the investigation of her private email server. That inquiry had concluded in July without charges, but the newly discovered laptop contained about 50,000 emails that might have been relevant. F.B.I. agents planned to go through them in due course, but several ranking officials did not see that any mad rush was called for, the Justice Department inspector general would later report. They believed — correctly, as it turned out — that the emails would be similar to the hundreds of thousands already examined.

Then Mr. Giuliani began dropping those broad hints of a “surprise,” adding that he knew F.B.I. agents were very upset. It seemed apparent to Attorney General Loretta Lynch that leaks were coming from the New York office of the F.B.I., according to the inspector general. Faced with the likelihood that word of the emails would be coming out one way or another, the F.B.I. director, James Comey, announced a review of the newly discovered cache. It played as a stunning piece of news, a fresh gust of scandal 11 days before the election.

Mr. Giuliani would later deny that he had heard about the emails from F.B.I. agents, though he had bragged about that in broadcast interviews.

Years before, he had shown that working with virtually nothing, he could cultivate the mere existence of investigations to his political benefit. Early in his first term as mayor, facing criticism over patronage hires, Mr. Giuliani and aides announced spectacular claims that a widely respected commissioner in the previous administration, Richard Murphy, had overspent his budget by millions of dollars for political reasons. Moreover, computer records seemed to have been destroyed in a suspicious burglary. The heat shifted from the reality of Mr. Giuliani’s patronage hires to the wispy vapors of the Murphy investigation. A year later, it emerged that Mr. Murphy had neither overspent nor done anything wrong, and that no records had been destroyed or stolen. Mayor Giuliani shrugged.