Rick Perry, the energy secretary who has drawn scrutiny for his role in the controversy surrounding President Trump’s efforts to push Ukraine officials to investigate the son of a political rival, told the president on Thursday that he would resign from the cabinet.

The Perry resignation had been anticipated for several weeks, even before the news emerged of his involvement in efforts to pressure the new president of Ukraine, Volodymyr Zelensky, to investigate a company that had worked with Hunter Biden, the younger son of former Vice President Joseph R. Biden Jr.

In the ensuing weeks, Mr. Perry has been drawn deeper into the questions around the pressure campaign on Mr. Zelensky, which has spurred an impeachment inquiry that threatens to engulf Mr. Trump’s presidency.

Mr. Perry told The Wall Street Journal in an interview published on Wednesday night that he was in contact with Mr. Trump’s personal lawyer Rudolph W. Giuliani about Ukraine-related matters at the direction of Mr. Trump.