MOSUL, Iraq — Defense Secretary Robert Gates said U.S. troops could remain in Iraq for years to come.

It would depend, he said, on what the Iraqis want and what Washington is willing to give.

Gates met soldiers of the 4th Advise and Assist Brigade, 1st Cavalry Division, in Mosul, where — like the troops Gates met one day earlier in Baghdad — they asked if they would actually be staying beyond 2011, and if so, for how long.

“Well, I think that would be part of any negotiation,” Gates answered, “... whether it would be for a finite period of time, whether it would be negotiated that there be a further ramp down over a period of two or three years, or whether we would have a continuing advise-and-assist role that we have in a number of countries that just becomes part of a regular military-to-military relationship.”

Any extension, however, would be smaller than the current 47,000-member force in Iraq.

During his travels, Gates nearly always meets small groups of deployed troops. Each time, he gives a short speech and answers questions on topics ranging from global policy decisions to getting washing machines and Internet connections fixed. The secretary shakes each hand, takes a picture and hands out hundreds of his personalized commemorative “challenge” coins – a military tradition.

“This is the high point of my trip. I appreciate you all taking the time,” he told 200 soldiers standing at attention under the sun at Baghdad’s Camp Liberty on Thursday. “I realize that it probably wasn’t necessarily voluntary.”

Lately, these speeches have been tinged with quieter and more emotional tones.

“This is still a dangerous mission,” he said Friday, noting that it was his 14th, and likely last, visit to Iraq. “I just wanted to come and say thank you and tell you that working with you has been the greatest privilege and the greatest honor of my life.”

On Thursday, shortly after shaking the last hand, out of earshot from the troops, Gates reflected on his tenure for reporters, saying, “I think the thing to remember is when I took this job I was asked what my agenda was, and I said: Iraq, Iraq, Iraq. Political heat was quite hot in Washington. Things were not going well here.”

He recalled that during his first press conference here in 2006, a firefight erupted in the background.

“And then in the spring we were losing up to 140 soldiers and Marines a month,” he said, softly. “It was a very tough time.”

Looking at today’s uprisings across the entire region, Gates said, “The amazing thing is a lot of these folks would be happy if they could get to where Iraq is today. It isn’t perfect, but it’s new. And it is a democracy, and people do have rights. ...

“It has been a long a painful journey for everybody. But, these young men and women, and those who’ve come before them, paid a terrible price to get this country to where it is today. And I think Americans should certainly take pride in what they have accomplished.”

baronk@stripes.osd.mil