The Afghan government could fall within weeks if Nato pulled out troops now, David Miliband warned today as he urged British opponents of the war to give the fight to rebuild the country more time.

In an interview with the Guardian at the end of a visit to Kabul for the presidential inauguration of Hamid Karzai, the foreign secretary said: "If international forces leave, you can choose a time – five minutes, 24 hours or seven days – but the insurgent forces will overrun those forces that are prepared to put up resistance and we would be back to square one."

At the end of a day spent visiting British troops and officials at the headquarters of the international military effort, Miliband said that Afghans were "sad that they need anyone, but they are passionate that my goodness they do – because if we weren't here their country would be rolled over".

He agreed that public anxiety about the war is growing in Britain as a result of rising casualties. "Afghanistan wasn't on the front pages until the last six months for obvious reasons," he said. "Now for tragic reasons there is a lot of interest. What we have to do is explain to people that the costs of staying are real but they are less than the costs of leaving."

He called for the three main party leaders to remain united in support of the war, despite growing unease, in particular from Nick Clegg, the Liberal Democrat leader. "Nick Clegg and David Cameron ask serious questions about different aspects of the campaign. They can do that , and they should be asked," Miliband said. But he challenged opponents of the war to show that retreat would not harm both Afghanistan and Britain.

"I don't think British opinion is about to flip to a position that says withdraw now," he said. "But there is a high degree of concern about the casualties, understandably, there is a high degree of concern about the complexity of effecting a strategy in a country with history as complex as this, and there is a high degree of concern about all the partners that we have got.

"There is a natural reaction to 18, 19, 20-year-olds, your neighbours, relatives and your friends being killed. It makes you ask, why are we there, can you succeed, is it worth it?"

Concerns about Karzai's failure to combat bribery and extortion in Afghanistan led Gordon Brown to warn earlier this month that he would not put UK troops "in harm's way for a government that does not stand up against corruption".

After meeting Karzai today Miliband said the Afghan president had asked him "to convey to the British people his gratitude for the sacrifices being made by British soldiers in defending his country. In particular he repeated to me, as he had to the prime minister, his condolences and his shock at the terrible killing of five British soldiers by an Afghan policeman."

The foreign secretary said Karzai's estimation of a three- to five-year deadline for the handover of security control to Afghan forces would not mean an end to western involvement. "My argument is not stay or go, my argument is we stay for a purpose, for a period, for progress," he said. "Artificial timetables just give succour to your enemy. We are going to transition, and transition is a better word than exit.

"The argument we have to take on is the argument that it is futile, and we have to take it on directly by saying that it is making a difference towards a goal – the goal is hard, but the goal is clear."

Miliband agreed that Britain should look beyond its military efforts in the south of the country.

"It is important we don't fall into a trap of 'Helmandshire', that we are creating a colony," he said.