U.S. Secretary of Defense Jim Mattis said Monday the United States does not intend to seize oil from Iraq, something President Donald Trump has in the past advocated as "spoils" for U.S military activity there and to prevent the Islamic State group from selling it.

Mattis spoke to reporters traveling with him to Iraq for an unannounced visit, which came on the second day of a military offensive to push Islamic State from the western part of the city of Mosul.

"I think all of us here in this room, all of us in America, have generally paid for our gas and oil all along, and I'm sure that we will continue to do that in the future," Mattis said. "We're not in Iraq to seize anybody's oil."

Later in Baghdad, Mattis also vowed to support Iraq through the fight against the Islamic State group.

"I assure you we are going to stand by you through this fight. We will stand by you and your army in the future so that your sovereignty is protected by the Iraqi forces and no one else," he said.

WATCH: Mattis on Iraqi oil

When asked if the United States would stay in Iraq after the battle for Mosul had ended, he said, "I imagine we'll be in this fight for a while and we'll stand by each other."

Lt. Gen. Stephen Townsend, who commands the U.S.-led coalition working to defeat Islamic State, was more explicit. "I don't anticipate that we'll be asked to leave by the government of Iraq immediately after Mosul. I think the government of Iraq realizes this is a very complex fight and they're going to need the assistance of the coalition even beyond Mosul."

On Monday, Iraqi forces advanced into the southern outskirts of Mosul on the second day of a push to drive Islamic State militants from the city's western part. Forces targeted a hill that overlooks the city's airport, entering the village of Abu Saif.

Mattis' stop in Iraq includes meetings with Townsend, as well as with Iraqi Prime Minister Haider al-Abadi and other Iraqi officials. Mattis is working on his own plan to accelerate the fight against Islamic State, which Trump ordered on January 28 be delivered to him within 30 days.

As the Mosul offensive began Sunday, Mattis said the U.S. role, which has been to conduct airstrikes and serve as advisers to Iraqi troops, will remain the same.

"The attack into the city is something I don’t want to go into details about because I owe confidentiality to the troops who are actually making the attack. At the same time, we are very close to it if not already engaged in that, in that fight," he said. "The U.S. forces continue in the same role that they were in East Mosul and the coalition forces are in support of this operation, and we will continue as you know with the accelerated effort to destroy ISIS."

Iraqi troops pushed Islamic State out of the eastern part of Mosul last month after a campaign that lasted more than 100 days. U.S. military officials have warned the fight for the western part of the city will likely be much tougher.

Iraqi special operations forces, regular army and federal police units are taking part in the offensive along with government-approved paramilitary forces.

The United Nations warned Sunday that hundreds of thousands of civilians are at risk in Mosul.

"The situation is distressing. People, right now, are in trouble,'' Lise Grande, the U.N. humanitarian coordinator for Iraq, said in a statement. "We are hearing reports of parents struggling to feed their children and to heat their homes."