Two thoughtful speeches this week dealt with the challenging legacy of America's war on terror. The first was given in London by Eliza Manningham-Buller, the former head of MI5. She spoke about the use of torture by American intelligence. Britain did not, she said, condone its use or carry it out directly, but nor did this country try as hard as it should have done (or perhaps at all) to discover what its allies were up to. As a result Britain gained information from suspects subjected to extreme and illegal techniques, while claiming that it did not condone the use of them. That is a greater matter for shame and scrutiny than the government seems able to admit, connivance being only one or two steps short of commission.

The second important speech this week was made in Boston by David Miliband, the man who as foreign secretary has had to deal with the consequences of torture and the wars which brought it about. His words repay close analysis, since they stand above the routine, as a signal to the future rather than a justification of the past.

"In 1988, I would never have believed that 2010 years later I would be British foreign secretary explaining a war in Afghanistan," Mr Miliband began. That was a clue to the direction of his thinking. He knows that the Afghan war has gone wrong, cannot be won in military terms and in the form it is being fought is destroying Afghanistan rather than saving it. He could not say this directly, but did so instead by proposing a change of strategy, in which dialogue and serious compromise matter more than fighting.

"Talking to the Taliban" has become an easy slogan for many critics of the war, but it has now also become official British and – in some regards – US policy. "A political solution to all conflicts is the inevitable outcome," the US general Stanley McChrysal said recently. Or as Mr Miliband put it in his speech: "While violence of the most murderous, indiscriminate and terrible kind started this Afghan war, politics will bring it to an end on the back of concerted military and civilian effort."

The foreign secretary does not need to persuade the British public. Six British deaths this month in Sangin alone are miserable evidence of the military struggle, and Mr Miliband is not the only politician who would like to see the fight come to an end. The American surge will not be sustained beyond 2011, as the presidential election comes closer. All this has added urgency to the search for an alternative. Tentative contacts with some Taliban figures, and a sham of an Afghan election to return a discredited president, are not in themselves a political solution.

A precipitate Nato pullout would require a latter-day version of the Soviet government's departing advice to its Afghan ally in 1989: "Forget Communism, abandon socialism, embrace Islam and work with the tribes." It would lead to the swift collapse of the Kabul regime, and chaos afterwards. But fighting on is no better. The answer, as Mr Miliband recognises, is some combination of less fighting and more talking, which could lead to a deal. This deal will not be the same as the "reconciliation" which has always been on offer – allowing Taliban fighters to surrender. The west and Kabul must compromise too. One target of Mr Miliband's speech was President Karzai, who has long since ceased to be anything other than an obstacle to a settlement. As the foreign secretary put it: "Without a genuine effort to understand and ultimately address the wider concerns which fuel the insurgency, it will be hard to convince significant numbers of combatants that their interests will be better served by working with the government than by fighting against it."

The conditions exist for a settlement. It would limit Taliban influence to the south, preserve advances such as female education, cut corruption and the number of foreign troops. Mr Miliband is right to be brave.