Bowing to pressure from the Republican-run Congress and abroad, the White House signed off on the proposal on Thursday after a fight that pitted the president against members of his own party and threatened to tarnish further a US image already soiled by the abuses at Iraq's Abu Ghraib prison.
Bush said the ban and accompanying interrogation standards will "make it clear to the world that this government does not torture and that we adhere to the international convention of torture, whether it be here at home or abroad".
After months of negotiations, McCain, a Republican senator from Arizona, declared "a done deal" that he said shows that the US "upholds values and standards of behaviour and treatment of all people, no matter how evil or bad they are".
"We've sent a message to the world that the US is not like the terrorists," McCain said while appearing with the president in the Oval Office to announce the agreement.
The agreement still needs to be approved by Congress, whose Republican leaders hope to adjourn for the year in a few days.
Under the deal, CIA and other civilian interrogators would be given the same legal rights that are guaranteed to members of the military who are accused of breaking interrogation guidelines, the officials said.
A day earlier, the House endorsed the Senate-passed ban, agreeing that the US needed to set uniform guidelines for the treatment of terrorist suspects and to make clear that US policy prohibits torture.
The US has drawn flak for its
treatment of terror suspects
That put pressure on the White House at a time when the president finds himself defending his wartime policies daily amid declining public support for the Iraq war and his own low standing in opinion polls.
The White House at one point threatened a veto if the ban were included in legislation sent to the president's desk, and Dick Cheney, the US vice-president, made an unusual personal appeal to all Republican senators to give an exemption to the CIA.
But congressional sentiment was overwhelmingly in favour of the ban, and McCain, a former navy pilot who was held and tortured for five years in Vietnam, adopted the issue.
As passed by the Senate and endorsed by the House, McCain's amendment would prohibit "cruel, inhuman or degrading treatment or punishment" of anyone in US government custody, regardless of where they are held.
It would also require that service members follow procedures in the Army Field Manual during interrogations of prisoners in Defence Department facilities.
In discussions with the White House, that language was altered to bring it into conformity with the Uniform Code of Military Justice. That says that anyone accused of violating interrogation rules can defend themselves if a "reasonable" person could have concluded that they were following a lawful order.
In recent weeks, the Bush administration had been seeking to add language that would offer protection from prosecution for interrogators accused of violating the provision. But McCain rejected that, arguing that it would undermine the ban by not giving interrogators reason to follow the law.
Supporters of the provisions say they are needed to clarify current anti-torture laws in light of abuses at Abu Ghraib in Iraq and allegations of misconduct by US troops at the detention centre at Guantanamo Bay.