WASHINGTON — James B. Comey, President Obama’s nominee for F.B.I. director, said on Tuesday that he no longer believed it was legal to waterboard detainees under United States law. His statements contrasted with the position he took in 2005 when, as President George W. Bush’s deputy attorney general, he oversaw the government’s legal opinions.

At his confirmation hearing before the Senate Judiciary Committee on Tuesday, Mr. Comey said that the government’s statute on the issue at the time was vague, complicating the ability of government lawyers to determine its legality. He said that despite his authorization of the opinions in 2005, he had urged senior Bush administration officials to end the use of the practice.

“Even though I as a person, as a father, as a leader thought, ‘That’s torture — we shouldn’t be doing that kind of thing,’ I discovered that it’s actually a much harder question to interpret this 1994 statute, which I found very vague,” Mr. Comey, 52, said at the hearing.

Many senators, legal scholars and human rights advocates have long believed that the 1994 statute clearly banned waterboarding.