Updated

MOSUL, Iraq -- U.S. Defense Secretary Robert Gates, visiting Iraq on the eve of the eighth anniversary of the fall of Baghdad, said Friday the United States could extend its troop presence in the country beyond the scheduled 2011 pullout.

Gates said that if Iraq wants American troops to remain, a deal could be negotiated for the long term or for as little as two or three years.

While all U.S. troops are scheduled to be out of Iraq by the end of this year under a deal negotiated in 2008 by the administration of President George W. Bush, it became clear during Gates' two-day Iraq visit that an extension is increasingly likely -- despite repeated public statements by Iraqi Prime Minister Nouri al-Maliki and other Iraqi officials that US troops are not needed any longer.

In remarks to U.S. troops at Camp Marez, Gates said that in his talks with a full range of top Iraqi officials they had indicated an interest in an extended U.S. troop presence.

"We're open to that," Gates said. "It obviously would be a presence that's a fraction of the size that we have here now."

He mentioned no numbers, but there currently are about 47,000 US troops in the country.

One soldier asked Gates how much longer the U.S. would stay if asked.

"That would be part of any negotiation," Gates replied.

He said it could be for "a finite period of time" at an agreed number of troops, or it could be a phased drawdown for two or three years beyond 2011.

Or, he said, it could be a long-term U.S. role to advise and assist Iraqi security forces "that just becomes part of the regular military-to-military relationship."

He added: "it just depends on what the Iraqis want and what we are able to provide and afford."

Gates spoke to the troops after meeting earlier in the day with Kurdish leaders in northern Iraq.

Gates visited Irbil for talks with Masoud Barzani, president of the Kurdish Regional Government, which is at the center of an unresolved struggle for power and resources in the semi-autonomous north.

The trip is Gates' 13th to Iraq as Pentagon chief. He told U.S. troops Thursday that this probably is his last visit to the country that American forces invaded in March 2003. Baghdad fell on April 9, 2003.