The six-day war is not over. Today, it brings the spectre of al-Qaida in Gaza

I am as old as this war. Officially the war of 1967, the year of my birth, lasted for six days. In reality, it's still going on: it is the 14,600-day war. Witness the violence in Gaza, one chunk of the territory which the young state of Israel - then just 19 years old - conquered in that extraordinary, whirlwind victory. In Gaza, there is fighting among the Palestinians - a barely repressed civil war between the old Fatah movement of Yasser Arafat and the Islamists of Hamas - but also between them and the Israelis. Hamas has resumed firing Qassam rockets from Gaza into Israel, a break in their ceasefire. On Monday, one rocket succeeded in killing a civilian, a woman in the southern Israeli town of Sderot. And Israel has resumed its targeted assassinations, including one attack on the home of a Hamas member of parliament, killing eight people. The war which marks its 40th anniversary in a fortnight may have brought Israel a breathtaking victory - but it has brought no peace.

Ever since I first travelled properly in Israel, as a young student, I came to believe that what had been won in 1967 was as much curse as blessing. Yes, Israel had done something remarkable, defeating the armies of three nations that had vowed its destruction. And yes, it salved the wounded psyche of Jews all over the world to see that, just two decades after Auschwitz, the Jews were not fated to be history's permanent victims, but could defend themselves and win. I understood the pride of 1967, the sense of recovered dignity that it brought; subliminally, as a child raised in the glow it brought, I even shared in it.

But I could see 20 years ago what Israel's first prime minister, David Ben-Gurion, had seen 20 years earlier. Even before the war was over, he was advocating a conditional withdrawal from the territories just won. He understood what holding on to those lands, and the Palestinian people who lived in them, would mean: a mortal, political and moral disaster for the state he had founded and loved.

The mortal threat is clear to this very day. The victory of 1967 turned Israel into a military occupier, and occupied people will always fight back eventually, as the Palestinians did in earnest with the first intifada that erupted in 1987, through the suicide bombings of the 1990s and the second intifada that began in 2000. Of course, the 40 years since 1967 have been most painful for those who have lived under occupation, the Palestinians of the West Bank and Gaza. But the inevitable consequence of that pain has been danger and perpetual conflict for the people of Israel.

The political threat is less visible, but just as obvious. Ben-Gurion understood what even Ariel Sharon would see three and a half decades later: that if Israel was to live up to its own ambition of being a Jewish, democratic state, it could not rule over a Palestinian Arab population that would one day be its numerical equal. Yet that is the statistical situation today, with equal numbers of Jews and Arabs in the historic land of Palestine. If Israel is truly democratic, and grants all those people the vote, it will no longer have a Jewish majority. If it remains Jewish, by excluding those people, then it is no longer democratic. This is the so-called demographic argument, the unavoidable choice for Israelis left by 1967: either you hold on to the West Bank and Gaza or you remain a democratic state with a Jewish majority: you can't do both.

The moral threat was doubtless furthest from the minds of those celebrating the reunification of Jerusalem, and the return of Judaism's holiest sites, 40 years ago next month. But occupation corrodes the occupier, slowly but unmistakably. Every time an 18-year-old Israeli conscript stops a man or woman at a checkpoint or presses the button for a "targeted assassination", the moral core of a country becomes a little bit smaller. Hard to believe that when Israel went to war in 1967, it enjoyed the sympathy of world opinion, who saw it as the plucky David against the Arab Goliath. In the 40 years that have passed, Israel's standing has plunged and the admiration of those days has turned into suspicion and worse.

For Israel's enemies, these changes are all causes for celebration. But not me. As someone whose family history is bound up with Israel, who wants to see that country survive and thrive, I lament what the "prize" of the West Bank and Gaza has brought. My great fear is that Israel is like a homeowner who has built two extra rooms on shaky ground: in wanting to keep hold of the extension, he risks losing the whole house.

The events of the last few days only lend that argument more force. The Palestinian Authority is in a desperate state, fighters nominally allied with the two main wings of its supposed "unity" government slaying each other on the streets of Gaza. The president's writ does not run; starved by an international embargo - maintained not just by Israel, but by the US and European Union - the society is grappling with deprivation. Those close to it warn that the PA is on the verge of collapse.

That could see Gaza fully transform into what it already resembles: a lawless, failed state, a Somalia on Israel's southern border. The kidnap of Alan Johnston and the Fatah-Hamas feud could be a harbinger of things to come, as warlords and militias slug it out ever more lethally. Some warn that into this vacuum could step those angels of death, al-Qaida, ready to mount a third intifada bloodier than anything Israelis have ever witnessed. "You're too late," says former EU mediator Alastair Crooke, "al-Qaida's already there."

Until now, Hamas has held the Islamist franchise in Gaza, fending off al-Qaida attempts to come on to its turf. But the latter is gradually acquiring a toehold, with the appearance of new groupings which give off the strong whiff of Bin Laden. The current violence in Lebanon, where a Palestinian group linked to al-Qaida is waging war from the refugee camp of Nahr al-Bared, is a warning of Gaza's future.

Even if al-Qaida does not supplant Hamas, by gaining momentum it could oblige Hamas to move in its direction. What is currently a grievance-based, nationalist movement with an Islamist hue - its main cause shaking off occupation - could become more rigid, more ideological, beyond the reach of reason and negotiation. This is a lesson Israel has failed to learn these last 40 years. If you refuse to deal with a group because it's too extreme, you don't get to deal with a more pliant, moderate alternative. On the contrary, you eventually confront a force that is even more extreme. It happened when Fatah was eclipsed by Hamas - and it could happen again.

What should Israel do? Right now, its leaders' sole objective is protecting civilians from rocket attacks: when Prime Minister Ehud Olmert visited Sderot on Monday he was booed. So his ministers speak of escalation, more targeted killings, perhaps even hitting the Hamas premier, Ismail Haniyeh. It's the same old mistake. Surely Israel's friends can begin to point in another direction: to seize on the hints from Hamas of possible compromise, to capitalise on the fact that Hamas too has an interest in defeating al-Qaida - and to begin a dialogue with the enemy. The aim would be to end the war that never ended - because the alternative is always so much worse.

Jonathan Freedland