It was at one of those meetings that Mr. Trump asked Mr. McCabe whom he had voted for, another person familiar with the encounters said. Mr. McCabe said he had not voted. The exchange was first reported by The Washington Post.

The question was unusually and overtly political for an interview related to a position in the Justice Department, which is supposed to maintain its independence from politics.

At their final meeting, Mr. Trump offered Mr. McCabe the job and told him he planned to give him the role of acting director. The president also said that he planned to make an appearance that week at F.B.I. Headquarters to bolster morale. Mr. McCabe told Mr. Trump that it would be a risky move after firing a well-respected director, so the president scuttled the trip, citing scheduling conflicts.

For weeks, Mr. Trump and his allies have focused their ire on Mr. McCabe. Mr. McCabe’s wife was a candidate for Virginia State Senate in 2015, and she received donations from the “super PAC” supporting Terry McAuliffe, the state’s governor at the time, who was a longtime ally of Hillary Clinton’s.

A White House official confirmed Tuesday night that Mr. Trump had asked the question, saying it was in the context of first asking about Mr. McCabe’s family, which led to a discussion about Mr. McAuliffe and then to how Mr. McCabe had voted. The F.B.I. declined to comment.