The head of MI6, Sir John Sawers, has described torture as "illegal and abhorrent" and defended the service's need for secrecy.
He said his organisation faced "real, constant operational dilemmas" to avoid using intelligence which had been gathered by torture.
He also said secrecy was "not a dirty word" and played "a crucial part in keeping Britain safe and secure".
He is the first serving MI6 chief to make a public speech in its 100 years.
The issue of torture came to prominence with the case of Binyam Mohamed, particularly when he was returned to the UK in early 2009.
He had been held in Pakistan in 2002 before US agencies moved him to Morocco, where he was severely tortured, and then ended up in Guantanamo Bay.
It then emerged that a British intelligence officer visited him in detention in Pakistan and that the CIA later told London what mistreatment the suspect had suffered.
Known in Whitehall as C, 55-year-old Sir John was speaking at a meeting of the Society of Editors in London.
He said: "Torture is illegal and abhorrent under any circumstances and we have nothing whatsoever to do with it.
"If we know or believe action by us will lead to torture taking place, we're required by UK and international law to avoid that action, and we do, even though that allows that terrorist activity to go ahead.
"Some may question this. But we are clear that it's the right thing to do. It makes us strive even harder to find different ways, consistent with human rights, to get the outcome we want.
"Suppose we received credible intelligence that might save lives, here or abroad. We have a professional and moral duty to act on it. We will normally want to share it with those who can save those lives."
Sir John said the UK's security service had a duty to ensure any partner service would respect human rights but admitted this was "not always straightforward".
He said: "Yet if we hold back and don't pass that intelligence, out of concern that a suspect terrorist may be badly treated, innocent lives may be lost that we could have saved.
"These are not abstract questions just for philosophy courses or searching editorials, they are real, constant operational dilemmas. Sometimes there is no clear way forward. The more finely-balanced judgments have to be made by ministers themselves."
Sir John said that the "most draining aspect" of his job was reading daily intelligence reports describing the plotting of terrorists "bent on maiming and murdering people in this country".
He added: "It's an enormous tribute to the men and women of our intelligence and security agencies and to our cooperation to our partners services around the world, that so few of these appalling plots develop into real terrorist attacks."
Sir John added that it was essential for MI6 agents and other intelligence agencies to be sure that their secrets were protected, in order to succeed in countering any terror threat.
Describing his organisation as the "secret front line" protecting Britain, he said: "Secrecy is not a dirty word. Secrecy is not there as a cover-up. Secrecy plays a crucial part in keeping Britain safe and secure.
"Secret organisations need to stay secret, even if we present an occasional public face, as I am doing today. If our operations and methods become public, they won't work. Agents take risks.
"They will not work with SIS [Secret Intelligence Service], will not pass us the secrets they hold, unless they can trust us not to expose them. Our foreign partners need to have certainty that what they tell us will remain secret, not just most of the time, but always."
Sir John also focussed on the fight against al-Qaeda, the need to prevent Iran acquiring nuclear weapons technology and combating cyber terrorism.
And he said there was "no single reason for the terrorist phenomenon".
He added: "Some blame political issues like Palestine or Kashmir or Iraq. Others cite economic disadvantage, distortions of the Islamic faith, male supremacy, the lack of normal checks and balances in some countries. There are many theories.
"But if we demand an abrupt move to the pluralism that we in the West enjoy, we may undermine the controls that are now in place. And terrorists will end up with new opportunities."
Sir John made reference to the 2004 inquiry into the Iraq conflict by Lord Butler. This said it was a "serious weakness" that caveats from intelligence chiefs were not spelled out in a September 2002 dossier, which set out the government's case for invading the country.
He said: "The Butler Review following Iraq was a clear reminder, to both the agencies and the centre of government, politicians and officials alike, of how intelligence needs to be handled."
Responding to the speech, Amnesty International UK director Kate Allen said: "More effective and independent oversight of the intelligence services is clearly needed.
"The Gibson Inquiry, announced by the UK government earlier this year, must be empowered to find out the truth about UK involvement in abuses overseas. And it must be as transparent as possible. We have had quite enough secrecy when it comes to these cases."