The UK's intelligence agencies cannot keep the country safe from terrorists if they cease all co-operation with repressive regimes "that don't fully live up to our standards", the foreign secretary has warned.

William Hague said the government had to "approach the world as it is, rather than as we would like it to be" if the security services were to thwart extremism abroad and prevent it from being imported into Britain.

But in a keynote speech to members of the Royal United Services Institute thinktank, the foreign secretary said the UK still intended to hold itself to the highest standards in terms of observing human rights, and suggested a new era of pragmatism was needed for working with countries with lower standards.

Hague said the UK intended to secure "justice and human rights partnerships" with countries with poor human rights records as a way of ensuring that intelligence passed to those regimes was not used for torture and the mistreatment of detainees.

"The threat from terrorism is greatest in the countries where the rule of law and human rights are weakest," he said. "When we detect a terrorist plot originating in a third country, we want to be in a position to share information to stop that planning, and do it in a way that leads to the arrest, investigation and prosecution of the individuals concerned in accordance with our own legal obligations and with their human rights respected at every stage.

"This gives rise to extremely difficult ethical and political decisions, such as whether to pass on information which might save lives and disrupt an imminent threat, but which could also create a risk of someone being mistreated if detained."

Hague said the UK received "credible assurances" from some countries that sharing intelligence would not lead to human rights abuses. "Where this is not the case, we face a stark choice. We could disengage or we can choose to co-operate with them in a carefully controlled way."

Speaking to an audience in Whitehall that included the head of MI6, Sir John Sawers, Hague admitted this approach "brings risk". "But I am clear that the risks of stepping back are greater still, placing our citizens at greater risk of terrorist attack."

Hague said the human rights partnerships would help countries to "investigate, detain and prosecute people to our standards". However, these agreements would not be set out in a treaty, they would remain secret and the Foreign Office would not publish a list of the countries it co-operated with, he added.

Instead, he set out five principles to ensure agreements were reached within an ethical framework. They included a pledge that every aspect of the co-operation would "require ministerial approval and oversight", and a promise that the government would work with countries only "where there is a serious and potentially long-running threat to the UK". Co-operation would be withdrawn immediately if the UK suspected its intelligence was being misused.

"We cannot keep our country safe if we are not co-operating at all with the countries that don't fully live up to our standards. Only a minority of countries in the world do that. We have to work with countries. Justice and human rights partnerships are a powerful framework for doing so," Hague said.

Cori Crider, legal director of the human rights group Reprieve, criticised Hague's speech. "We've been here before. From Afghanistan to Libya, the UK has handed over detainees or colluded in renditions, knowing that the result will be that people face torture," she said.

"The government has sought to spare its blushes by obtaining 'assurances', but these have not been worth the paper they were printed on. William Hague is trying to find a way to join hands with the torturer while keeping his own hands clean. It just won't work."