Defense Secretary James N. Mattis made an unannounced visit to Iraq’s capital on Monday to reassure allies of the U.S. military’s commitment to support the sprawling operation to recapture the city of Mosul from entrenched Islamic State militants.

Ahead of the trip, however, Mattis made clear he did not advocate President Trump’s oft-stated wish to take Iraq’s oil.

Such an undertaking would be illegal and require decades of occupation by hundreds of thousands of troops, and likely cost more money than could be earned from the oil.

“All of us … in America have generally paid for our gas and oil all along and I’m sure we will continue to do so in the future,” Mattis said. “We’re not in Iraq to seize anybody’s oil.”

Trump, as a candidate and as president, has repeatedly said that the U.S. should have “taken Iraq’s oil,” including at CIA headquarters on just one day after his inauguration last month.

“The old expression, ‘to the victor belong the spoils’ — you remember,” he said. “I always used to say, ‘Keep the oil.’ I wasn’t a fan of [the war in] Iraq. I didn’t want to go into Iraq. But I will tell you, when we were in, we got out wrong … .

“If we kept the oil, you probably wouldn’t have ISIS because that’s where they made their money in the first place. So we should have kept the oil. But OK. Maybe you’ll have another chance. But the fact is, should have kept the oil,” he said, using an acronym for Islamic State, the militant group that seized oil fields in Iraq and Syria and sold their output on the black market.

Iraq’s economy is nearly entirely reliant on oil and it remains the lifeblood for Iraqi Prime Minister Haider Abadi’s fragile government as it tries to provide basic services to citizens and maintain the nation’s aging infrastructure.

Legal experts have said the U.S. seizure of Iraqi oil would have violated decades of international law, including the Geneva Conventions.

When Mattis stepped off the C-17 cargo plane Monday morning, it marked his first return to the war-torn country where he spent years in combat as a Marine Corps officer before retiring as a four-star general in 2014.

He’s set to have face-to-face talks with Abadi and other senior Iraqi government officials, whom he called “our partner in this fight” against Islamic State. Iraqi ground forces began the assault Sunday to retake Mosul, Iraq’s second-largest city.

The operation, backed by U.S. air power and special forces, is expected to take months.

“We’re going to make certain that we have good shared situational awareness of what we face as we work together, fight alongside each other to destroy ISIS,” Mattis told reporters Sunday before the trip.

Iraq is also one of seven countries named in Trump’s temporary ban on travelers that was put on hold by the courts. Trump’s ban caused anger in Iraq, where members of parliament considered retaliating by refusing to grant visas for U.S. nationals.

While the Trump administration intends to issue another version of the ban, Mattis said he was promised that it would shield the thousands of Iraqi interpreters, advisors and others who have assisted the American military in Iraq.

“Right now, I am assured that we will take steps to allow those who have fought alongside us, for example, to be allowed in to the United States,” Mattis said. “They will be vetted obviously by their performance on the battlefield beside us.”