Rear Adm. Kevin M. Sweeney has resigned his post as chief of staff to the United States secretary of defense, the Defense Department said Saturday.

Mr. Sweeney had become chief of staff to former Defense Secretary Jim Mattis in January 2017, and his resignation comes soon after Mr. Mattis’s own pointed departure in December. The two had known each other for years.

Mr. Mattis said then that he had resigned in protest of President Trump’s decision to withdraw American forces from Syria and in protest of the president’s rejection of international alliances.

Mr. Mattis had originally said he would step down at the end of February, but angered by Mr. Mattis’s criticism, Mr. Trump said he was removing Mr. Mattis from his post two months early.