WASHINGTON — Former Gov. Mark Sanford of South Carolina said on Tuesday that he was ending his long-shot primary challenge to President Trump just two months after announcing it, arguing that the impeachment inquiry had made it impossible for his message of fiscal conservatism to break through.

“You’ve got to be a realist and what I did not anticipate is an impeachment,” Mr. Sanford said at a news conference in Concord, N.H., where he announced the end of his campaign.

Mr. Sanford conceded that his bid had been “a long shot, but we wanted to try and interject this issue, how much we’re spending, into the national debate, which comes along once every four years.” He said he found no “appetite for a serious nuanced debate with impeachment in the air.”

During his short-lived, quixotic campaign, Mr. Sanford made it clear he did not support the impeachment inquiry unfolding on Capitol Hill. And unlike the other two Republican primary challengers in the race, Mr. Sanford never mounted an argument based on Mr. Trump’s fitness for office, saying instead that he would support Mr. Trump in a general election if he became the party’s nominee.