Gates said the offensive that began last month is encouraging, but he stopped short of saying the success in Marjah suggests that the war is at a turning point. The Marjah campaign routed most Taliban fighters from a town they once controlled, without a high casualty toll for U.S. troops and the Afghan security forces fighting alongside them.
Despite what he called positive signs, Gates cautioned against optimism.
"People still need to understand there is some very hard fighting, very hard days ahead," Gates told reporters traveling with him for the unannounced visit.
Meanwhile, Iran is "playing a double game" in Afghanistan, trying to woo the Afghan government and undermining U.S. and NATO efforts by helping the Taliban, Gates said. Iranian President Mahmoud Ahmadinejad was also visiting Afghanistan this week.
Gates had an unusually provocative warning for Tehran should it carry efforts to help the Taliban too far.
"They also understand that our reaction, should they get too aggressive in this, is not one they would want to think about."
Pentagon press secretary Geoff Morrell later said Gates was referring only to actions the United States might take inside Afghanistan and not to a wider confrontation with Iran.
During his visit, Gates is scheduled to meet with his top military commanders and senior Afghan officials.
"The early signs are encouraging but I worry that people will get too impatient and think things are better than they actually are," Gates said.
The war is now in its ninth year and unpopular with a majority of Americans. The challenge for the Obama administration is to demonstrate clear progress against the entrenched Taliban insurgency this year, when the number of U.S. forces in the country will reach roughly 100,000 - nearly triple the size of the force when Obama took office.
Afghan President Hamid Karzai has invited Taliban participation in a spring peace conference, but U.S. officials have suggested that it is too soon to hold such a session.
The United States supports reconciliation efforts with the Taliban under certain conditions, but Gates and others have said that effort is only likely to succeed when the Taliban have been battered militarily and see that they are losing support from ordinary Afghans.
"My guess is they are not at that point yet," Gates said.
The Marjah offensive is the largest combined operation since the 2001 U.S.-led invasion to topple the Taliban regime. The offensive in the southern Afghan town of 80,000 is also a precursor to a larger operation planned for later this year in Kandahar, the largest city in the south and the former Taliban headquarters.
The task following the three-week military campaign is to convince Marjah residents that the civilian government can provide them with a better life than the Taliban. But during a visit there Sunday, Karzai heard complaints from them about corruption among former Afghan government officials, looting and international forces detaining innocent civilians.
The man appointed as the new civilian chief in Marjah has also come under scrutiny. Abdul Zahir has a violent criminal record in Germany.
Zahir has said the allegations of a criminal record were "all a lie" and Western officials say they are not pushing to oust him.
Gates said he knows little about the allegations and would ask U.S. and Afghan officials for their views.
"The question is if the guy committed a crime and served the time, then does that automatically rule him out? I just don't know the answer to that question," Gates said.