WASHINGTON — The Pentagon’s assistant defense secretary for international security affairs, Robert Karem, is leaving his Senate-confirmed post to work for Senate Majority Leader Mitch McConnell.

Karem departs the far-reaching Pentagon policy job 18 months after the Senate confirmed him and two weeks before midterm elections to advise McConnell, R-Ky., and the Senate Republican Conference on matters of national security, foreign policy, defense and the intelligence community.

A former staffer to McConnell and other Republican leaders in Congress, Karem replaces Thomas Hawkins, who left the Senate majority leader’s office to join vehicle manufacturer Oshkosh last month as its senior vice president for government relations.

The departure may leave a void at the Pentagon, where Karem served as the principal adviser to Defense Secretary Jim Mattis on policies relating to the Middle East, Europe (including NATO), Russia, Eurasia, Africa and the Western Hemisphere. His tenure coincides with a pivot at the Pentagon toward Russia and China, and greater congressional scrutiny of the military’s role in places like Niger and Yemen.

The Pentagon confirmed that Katie Wheelbarger, the principal deputy assistant secretary of defense for international security affairs, would take over the job on an acting basis.

Though it is rare for a Pentagon political appointee to leave for a Senate staff position, Karem’s new job in Congress will cover the breadth of defense issues, including budgetary matters, according to National Defense Industrial Association board member Arnold Punaro, a former Marine Corps lieutenant general who served as a Senate Armed Services Committee staff director from 1987 to 1997.

“It’s a very influential position, working for the majority leader,” Punaro said, praising Karem as “the Rock of Gibratar” in the Pentagon’s policy shop, where he had served for a time as acting undersecretary for policy. (Karem was confirmed to his job roughly four months before the Senate confirmed David Trachtenberg to be the principal deputy undersecretary of defense for policy.)

During Karem’s tenure, he made headlines for his Capitol Hill testimony the U.S. troop presence in Syria is aimed at defeating the Islamic State group, but also has the “residual benefits” of deterring Iran. The statement came amid concerns troops who are not authorized to confront Iran may nonetheless be drawn into an conflict with far-reaching implications.

“Our military operations in Syria are squarely focused because of the authorities we have been provided against ISIS and al-Qaida,” Karem said. “It is, of course, the case that our presence in Syria, our military presence has residual benefits, benefits for our diplomats who are trying to seek a negotiated end to the conflict and residual benefits because it can help deter activities from other adversaries.”

On Wednesday, McConnell praised Karem’s experience and career of service.

“I’m thrilled to welcome Robert back to our team in such a key role,” McConnell said in a statement. “Senate leadership and the entire Republican Conference will benefit greatly from his counsel built on years of service and experience.”

Prior to his nomination, Karem served on President Donald Trump’s transition team as an adviser to then-CIA director nominee Mike Pompeo. Previously, Karem was the principal foreign policy adviser to Jeb Bush, who ran for president.

Karem has also served in the House of Representatives as the national security adviser to Majority Leaders Eric Cantor and Kevin McCarthy, where he was responsible for managing a wide range of foreign policy, defense and intelligence issues for the House Republican Conference.

Karem was also a member of then-Vice President Dick Cheney’s national security staff from 2005 through 2008.

Aaron Mehta in Washington contributed to this report.