An Afghan acquaintance who had worked for the United States Agency for International Development (USAID) told me several years ago how an Afghan subcontractor had made a large profit from a contract to build and get running a tractor repair shop in Uruzgan province in southern Afghanistan. Uruzgan, the home province of Mullah Omar, the leader of the Taliban, was then a particularly dangerous place, but the subcontractor cunningly turned this to his advantage. The strong Taliban presence in the area meant that nobody from the main contractor or USAID, which was funding the project, could visit the site of the new repair shop. Instead, they relied on photographs emailed to them which showed that the work was making impressive progress.

The head of the subcontractor did not go near Uruzgan, but instead rented an existing tractor repair shop in one of the safer parts of Kandahar. Along with the shop, he hired young men for a few days who were told to look as if they were busily fixing tractor engines. A photographer took pictures of all this which, when emailed to Kabul, convinced the donors and main contractor that the contract was being fulfilled.

My acquaintance had other stories of his time with USAID. "I went to see a food-processing plant in the east of the country which was meant to employ 250 women," he said. "We had started the project and were paying for the equipment and the salaries. But all I found was a few people working on a vegetable plot the size of a small room." He asked local officials about the non-existent processing plant and was warned to keep his mouth shut. They said, "if I did not keep quiet, there would be trouble on the road back to Jalalabad – in other words they would kill me".

Download the new Independent Premium app Sharing the full story, not just the headlines

I found these stories amusing at the time but, driving through Kabul one evening a few days later, I saw a man standing in the half-frozen mud – it was in December – selling second-hand clothes. When I stopped to talk him, he told me his name was Abdul Qudus and he used to clean carpets but had lost his job two years earlier. "I buy and sell clothes for between 10 and 30 Afghanis [11p-32p] and even then there are people who are too poor to buy them," he said. "I myself am very poor and sometimes I don't eat so I can feed my children."

I thought bitterly of the torrent of aid that had flowed into Afghanistan since 2001 – the latest figures give US non-military aid alone as $100bn (£61bn) – which had done so little good to Mr Qudus and millions of other Afghans. Some 60 per cent of Afghan children are stunted due to malnourishment and only 27 per cent have access to safe drinking water. "Things may look all right to foreigners but in fact people are dying of starvation in Kabul," Mr Qudus told me.

The maladministration and wastefulness of the international aid effort in Afghanistan since 2001 are a staple of journalistic commentary, to some extent rightly. But the average lifespan of Afghans has risen from 45 years in 2001 to 62 today, an improvement due largely to a sharp drop in child mortality. In 2001, one in four Afghan children died before the age of five compared with one in 10 today. The reason for this dramatic progress is improved public health with better vaccination, midwifery and access to health care. Key to this development is $100m from USAID, so often the target of critics, without which the child mortality rate might have stayed where it was.

"International aid" brings out the best and worst in people and institutions. It may be the occasion for appalling corruption and wastefulness or it can make the difference – as in the case of Afghan public health – between life and death for millions. There are aid workers who live a colonial lifestyle and never leave their offices, and others who show extraordinary skills and endurance. In the mid-1990s I came across a hospital in Iraqi Kurdistan, then sealed off from the outside world, which was supplying and fitting artificial limbs to people who had stepped on one of the millions of mines that littered the landscape. Villagers had been trying to make a little money to buy food by defusing mines and selling the explosives and the tin foil in which they were wrapped. Without the NGO-run hospital, few of these legless people would have survived. Likewise in 2001, life in the rebel-held Panjshir Valley was of medieval harshness, but at the bottom of the valley was a state-of-the-art Italian hospital.

The picture is very varied. Wartime is not a good moment to start big long-term infrastructure projects. Insurgents know these are politically inspired and intended as a signal that the Afghan or Iraqi governments are doing something for their people. Naturally, they will try to sabotage such projects with mines, assassinations and general intimidation. An outstanding example of this in Afghanistan is the Kajaki hydroelectric dam on the Helmand River, originally completed by USAID as long ago as 1953, but needing a third turbine, ultimately brought in by British troops but never installed.

The dam project is today the subject of an angry dispute between USAID, which is funding it, and the US Special Inspector General for Afghanistan Reconstruction, John Sopko, who says it has become too expensive to be worthwhile. He says that in 2001 the scheme was expected to cost just $17m but this has since risen to $345m. These figures are vehemently contested by USAID.

As Iraq and Afghanistan are two of the most crooked and dysfunctional states in the world, it is unlikely that international aid, along with everything else, will be untainted by corruption and incompetence.

It does not have to be like this. Critics of non-governmental organisations and international aid in general will be glad to learn that there is one place in the world where the NGOs have been expelled and local people are running their own project. But the anti-aid lobby may be taken aback by the identity of those running the anti-NGO campaign.

They are, in fact, al-Shabaab, the local affiliate of al-Qa'ida in Somalia, who control the Lower Shabelle province, now once again the bread basket of the country. Al-Shabaab has put $2m of its funds into a canal-building project that has brought prosperity to local farmers who no longer depend on the uncertain rains. "We want our people to be free of NGOs and foreign hands. We want them to depend on each other and to stand free of outsiders," Sheikh Abu Abdullah, the al-Shabaab governor of Lower Shabelle told al-Jazeera.

Mohammed Sheikh Abdi, the head of a local farmers' union, attributes the new prosperity to the NGO ban. "They bought their food from abroad and never bought from us local farmers," he says. "They killed every incentive to farm. We were hostages to the NGOs." Perhaps the lesson to be drawn from this is that the projects which succeed are modest in scale, easily monitored, produce immediate benefits and where all know that corruption will be inevitably punished.