Next week marks the 40th anniversary of an event that seemed to turn the world upside down. In the early hours of January 31 1968, soldiers of the National Liberation Front of South Vietnam and the army of North Vietnam launched what came to be known as the Tet offensive (it coincided with Tet Nguyen Dan, the lunar new year) against the US military and its local allies.

The insurgents struck simultaneously across the country, targeting more than 100 cities and towns in what the historian Stanley Karnow describes as an offensive "of extraordinary intensity and astonishing scope ... audaciously shifting the war for the first time from its rural setting to a new arena - South Vietnam's supposedly impregnable urban areas". Military installations, police stations, prisons, government offices and radio stations came under attack. Most spectacularly, a group of 19 commandos fought their way into the US embassy compound in Saigon, where they held out for six-and-a-half hours - long enough for the images of defiance to be broadcast around the world.

Hue, the ancient capital and the south's third-largest city, was only recaptured by the US after 25 days of house-to-house fighting. Atrocities against the civilian population were committed by both sides, and by the battle's end 116,000 of the city's population of 140,000 were homeless.

NLF and North Vietnamese casualties reached terrifying proportions. Perhaps a half - 45,000 - of the soldiers engaged in the initial offensive were killed. What is more, they were unable to hold any of the ground they had seized. The aim had been to spark a popular uprising in the South. When that did not materialise, partly because the communist party was weak among urban workers, the US's superior armaments prevailed.

The US counter-offensive was ferocious and indiscriminate. Urban areas held by the NLF were pulverised. Within two weeks, 630,000 civilians had been made refugees. On February 7, when the US recaptured the charred wasteland of what had been the town of Ben Tre, a US major told the press: "It became necessary to destroy the town in order to save it." Soon after, in the course of flushing out alleged collaborators in Saigon, the chief of South Vietnam's national police was filmed calmly shooting a bound prisoner in the head. This image also went round the world, further eroding US claims to moral purpose.

Years later, General Tran Do, one of the architects of the offensive, commented: "In all honesty, we didn't achieve our main objective, which was to spur uprisings throughout the South. Still, we inflicted heavy casualties on the Americans and their puppets, and this was a big gain for us. As for making an impact in the United States, it had not been our intention - but it turned out to be a fortunate result."

For an American public reared on a belief in US supremacy, Tet was a shock. For three years they had been assured that the war in Vietnam was being won. Now the disparity between US government claims and the reality on the ground became untenable. The antiwar movement was vindicated. In the New Hampshire primary, held on March 12, President Lyndon Johnson was embarrassed by the strong showing of antiwar candidate Eugene "Gene" McCarthy. On March 31, two months after Tet, he announced that he would not seek re-election and offered to open negotiations with the North Vietnamese, who accepted on April 3.

Tet caused fear and trembling in the corridors of power, but in the wider world the spectacle of the greatest power on earth defeated by an army of poor people inspired millions. The student revolts for which 1968 is famous took off in the wake of Tet, first in Germany and Italy, spreading subsequently to the US, France, Mexico and Pakistan.

However, the US war in Vietnam was to continue in its destructive fury for another four years. US policy did change after Tet - towards "Vietnamisation", in which reliance on air power increased. US casualties fell, from 16,000 killed in 1968 to 600 in 1972. On the other side the toll rose. Perhaps half the 5 million killed in the war, according to Vietnam government figures, perished during these post-Tet years.

Here is the ominous lesson for Iraq. There are few things as dangerous as an imperial power in retreat. Yes, the war is discredited and the major presidential candidates promise to reduce US troop numbers. None, however, seems prepared to abandon the mission in Iraq, which is also propped up by an array of corporate interests. As Vietnam showed, the alternative to a prompt and complete withdrawal is not a happy compromise, but prolonged devastation.

· Mike Marqusee is the author of Redemption Song: Muhammad Ali and the Spirit of the Sixtiesmikemarqusee.com