Gates said he will continue on the course with Iraq, which he said would be his highest priority if confirmed as expected.
Gates, 63, said he believes George Bush, the US president, wants to see Iraq improve to the point where it can govern and defend itself, while seeking a new approach.
On Iran, Gates said that military action against Iran would be an absolute last resort, "unless the vital interest are threatened", he said, but ruled out any attacks against Syria.
Gates said Iran was trying to acquire nuclear weapons and that its leaders were lying when they said their programme is strictly civilian.
"Yes sir, I do," he said in response to a question from the Senate panel considering his nomination on whether he believed Iran was seeking a nuclear weapons capability.
"An attack on Syria would give rise to anti-Americanism in the region and is not beneficial for American ties with neighboring countries," he said.
"What we are now doing is not satisfactory," Gates said.
"In my view, all options are on the table, in terms of how we address this problem in Iraq."
Asked directly by Carl Levin, a Democrat senator, whether the US is winning in Iraq, Gates replied: "No, sir."
However, at the outset of the second session of questions about Iraq and other subjects, Gates began by telling the committee he wanted to amplify on his remark about not winning in Iraq.
He did not withdraw the remark but said: "I want to make clear that that pertains to the situation in Iraq as a whole."
He said he did not want US troops to think he believes they are being unsuccessful in their assigned missions.
He said: "Our military wins the battles that we fight.
"Where we're having our challenges, frankly, are in the areas of stabilisation and political developments and so on."
Gates believes the US had too few troops at the outset of the war in 2003.
He said: "I suspect in hindsight some of the folks in the administration would not make the same decisions they made, including the number of troops in Iraq to establish control after Saddam Hussein's regime collapse.
"Our course over the next year or two will determine whether the American and Iraqi people and the next president of the United States will face a slowly but steadily improving situation in Iraq and in the region or will face the very real risk, and possible reality of a regional conflagration."
He also told senators that he believes a political solution in Iraq is required to end the violence.
At the White House, Tony Snow, the press secretary, was pressed by reporters about Gates' answer that the US is not winning in Iraq - one that seemed to be in conflict with the president's own position.
Snow said that Gates' testimony, taken in its entirety, shows he shares Bush's view that the US must help Iraq govern and defend itself.
Snow told reporters: "I know you want to pit a fight between Bob Gates and the president, it doesn't exist.
"If you want to try get a nuanced and full understanding of where Bob Gates stands on these issues with regard to the president and his policies and the definition of what it is to win and Iraq and what it takes, then I think you're going to find he agrees [with Bush]."
The confirmation hearing comes amid intensifying pressure on Bush to take a new approach in Iraq, reflecting the outcome of the November 7 elections that put Democrats back in control of both houses of Congress.
Democrats and some Republicans have pressed Bush to begin withdrawing some of the 140,000 US troops in Iraq.
US deaths in Iraq are approaching 2,900 and the relentless fighting and escalation in sectarian violence are raising questions about whether Iraq will enter a civil war, and whether the government of Nuri al-Maliki, the Iraqi prime minister, can ever be effective.