Asked on Wednesday whether he was considering replacing Hegseth, whom he has described as a champion of the war, Trump told reporters: "No, I think he's doing a very good job."
The response contrasted with then-president George Bush, who fired Defence Secretary Donald Rumsfeld the morning after the 2006 midterms, when voter discontent over the Iraq war helped Democrats win control of Congress.
But sources said Trump could still replace Hegseth as Republicans assess their losses.
One Trump adviser said Hegseth "could be on the chopping block" because of the war.
"Someone is going to get blamed for this and you know it's not going to be him (Trump)," the adviser said.
Trump has described Hegseth as a key proponent of the unpopular conflict, saying on March 23: "Pete, I think you were the first one to speak up, and you said, 'Let's do it, because you can't let them have a nuclear weapon.'"
On Wednesday, Vice President JD Vance publicly questioned whether the Iran war was worth it and said it cost Republicans control of Congress.
Asked for comment, the White House referred Reuters to Trump's public remarks on Hegseth.
The Defence Department said Hegseth was "one hundred per cent committed" to leading the Pentagon until the end of Trump's term, which ends on January 20, 2029.
Hegseth has been a polarising figure in American politics and has made enemies even within his own Republican Party. One Republican lawmaker, US Representative Thomas Massie, even filed articles of impeachment against him earlier in 2026, accusing him of abusing his office by launching hostilities against Iran without approval by Congress.
Democrats have promised to investigate Hegseth and his handling of the Pentagon, and aides say that could include everything from his handling of the Iran war to his purges of top military officers including the chairman of the Joint Chiefs of Staff.
He could also face scrutiny over his Ukraine policy and US military strikes on suspected drug trafficking boats in Latin American waters, which some Democrats say could amount to war crimes.
One long-rumoured possibility for Hegseth would be filling the Senate seat that will be vacated by Senator Marsha Blackburn, who was elected on Tuesday to become Tennessee's next governor starting in January.
Trump has regularly praised Hegseth publicly, and has given the former Army National Guard soldier significant leeway as he sought to reshape the Pentagon.
But in October, Trump publicly split with Hegseth by pulling the plug on his plans to livestream the Army's firing-squad execution of Fort Hood shooter Nidal Hasan.
Many fellow Republicans, along with religious leaders and international observers, raised objections to the plan. Defence officials privately expressed relief that the livestreaming would not go forward.