When a top Justice Department official called him on March 10 to ask for his resignation, Mr. Bharara said he thought it was a mistake. He said it took nearly 24 hours before Justice Department officials could finally tell him whether the president actually wanted him fired.

“Literally, no one was giving us an answer to that question,” Mr. Bharara said.

Mr. Bharara spoke to The New York Times on Monday, his first day as a distinguished scholar in residence at New York University School of Law. On Thursday night, he is to deliver a lecture at The Cooper Union in Manhattan.

He said he was uncertain about his plans, but reiterated that he had no interest in seeking public office. He has had some time to contemplate life after being a prosecutor; in the interview, he said he initially expected that, like all United States attorneys, he would be asked to resign once Mr. Trump took office, a request that he said would have been “perfectly appropriate.”

His expectations began to change on Nov. 16, when he said he received a call from Senator Chuck Schumer, Democrat of New York, for whom he had once worked as chief counsel and who had recommended him to Mr. Obama for the United States attorney post.

Mr. Schumer told Mr. Bharara he had gotten a call from Mr. Trump during which the president-elect said he wanted Mr. Bharara to stay on. That led to a meeting on Nov. 30, on the 26th floor at Trump Tower. Jared Kushner, Mr. Trump’s son-in-law, and Stephen K. Bannon, his chief strategist, were waiting, Mr. Bharara said.

When Mr. Trump entered the room 10 to 15 minutes later, Mr. Bharara recalled, he quipped, “This guy gets better press than me.” Mr. Trump said he had read for years about the office’s work under Mr. Bharara, and praised its accomplishments.

Mr. Bharara said he spoke briefly about his office, emphasizing that it prized its independence, and that he presumed that was why Mr. Trump wanted him to stay. He would be honored, he said he told Mr. Trump, to continue in the job.