Mr Gates also served under President George W Bush
President Barack Obama's new cabinet sees Afghanistan as its "greatest military challenge", the US defence secretary has told Congress.
Robert Gates also said the policy remained that the US would "go after al-Qaeda wherever al-Qaeda is".
International co-ordination of the fight against the insurgency had been "less than stellar", he admitted.
About 3,000 extra US troops were recently deployed south of the Afghan capital, Kabul.
The soldiers from the 10th Mountain Division moved into the provinces of Logar and Wardak, Nato officials said.
They appear to be the first batch of up to 30,000 additional American troops destined for Afghanistan. The US currently has about 34,000 troops in the country.
Mr Gates said the Pentagon would probably be in a position to deploy three more combat brigades to Afghanistan by mid-summer but infrastructure would have to be expanded before a fourth could be sent in.
Each of the brigades due to be deployed has about 3,500 soldiers.
"President Obama has made it clear that the Afghanistan theatre should be our top overseas military priority," Mr Gates told the Senate Armed Services Committee.
He said civilian casualties "are doing us enormous harm" in Afghanistan, and US forces had to do better to avoid innocent deaths.
"My worry is that the Afghans come to see us as part of the problem, rather than as part of their solution. And then we are lost."
At his first hearing since President Obama took over last week, the defence secretary was also questioned about future policy on al-Qaeda, the militant network which claimed responsibility for the 9/11 attacks on America.
He replied that the US would "go after al-Qaeda wherever al-Qaeda is", and confirmed that the government of Pakistan had been informed of that intention.
US drones fired missiles into Pakistan's north-western regions of North and South Waziristan on Friday, killing at least 14 people, according to intelligence officials and residents.
It was the first such attack on the area, a stronghold of al-Qaeda and Taleban militants, since George W Bush left office.
Mr Gates stressed that in Afghanistan, as in Iraq, there was "no purely military solution".
Insurgents have been able to strike inside the capital Kabul
"While this will undoubtedly be a long and difficult fight, we can attain what I believe should be among our strategic objectives: an Afghan people who do not provide a safe haven for al-Qaeda, reject the rule of the Taleban and support the legitimate government that they elected and in which they have a stake," he said.
Reiterating a long-held US appeal for its allies to commit more combat troops, he said that parts of Afghanistan had come increasingly under insurgent control.
"It is also clear that we have not had enough troops to provide a baseline level of security in some of the most dangerous areas - a vacuum that increasingly has been filled by the Taleban," he said.
The defence secretary also warned that new "setbacks" in Iraq were possible.
"There may be hard days ahead for our troops [in Iraq]," he said while noting that violence there had remained low.