The fluid national identities of the new world mean that people often end up delineating countries in pairs. Malaysia is contrasted with Indonesia, Brazil with Argentina, as if the comparison told us something profound about both.

Often, there is a moral element to all this. Those who deplore the behaviour of the sprawling, cosmopolitan USA wonder why it can't be a little more like its sprawling, cosmopolitan neighbour Canada; those who now condemn Australia long for it to become more like its tolerant neighbour, New Zealand.

The contrast was never clearer than in August 2001 when, in a blatant piece of pre-election opportunism, Canberra's rightwing government whipped up a xenophobic storm by refusing to allow refugees to land on Australian soil after they were saved from drowning by the Norwegian freighter Tampa.

New Zealand, keen to help out a more powerful neighbour, demonstrate its own ethical credentials, and help out the refugees caught in the middle, offered asylum to 150 of them without hesitation.

The action cemented an image in the public mind, or at least in the mind of the worldwide left: Australia bad, New Zealand good.

It is an image that in many ways New Zealand lives up to. The founding legal act of modern Australia was the description of the country as terra nullius, a land unoccupied by its Aboriginal population and ripe for European invasion. In New Zealand the counterpart was the Waitangi treaty, which theoretically guaranteed the Maori title to their land.

Australia's 824 state and federal parliamentary seats provide room for just two indigenous people, whereas New Zealand's 122 MPs include 20 Maori. New Zealand has also never been shaken by an electoral earthquake like that stirred up in Australia by Pauline Hanson and her racist One Nation party in the late 1990s.

Others might point to the fact that the governor general, prime minister and attorney general, who head the three traditional branches of government, are all women; that there is a male-to-female transsexual in the governing party; or that the Greens, whose MPs include a dreadlocked rasta, briefly made up the second biggest party in the government's ruling coalition.

But the complexion of a sitting government should not always be taken to represent that of the country as a whole, and there are cracks in New Zealand's tolerant self-image.

The most worrying of them at the moment is spreading around the figure of Ahmed Zaoui, a member of Algeria's Islamist FIS party which was deposed after winning the country's 1992 elections.

He sought asylum in New Zealand just over a year ago, and since then he has been held in detention, accused by the spy agency SIS of being a threat to national security and threatened with deportation back to Algeria, where he faces a death sentence.

Were it not for his situation, it would be easy to regard the whole thing as Kafkaesque farce; certainly, there has been a touch of the keystone cops in his treatment.

When Zaoui arrived at Auckland airport last December, a translation error resulted in officials believing he had owned up to being a member of the GIA, a brutally militant Algerian Islamist group. Before the mistake could be corrected, it was flashed to Interpol offices on five continents.

Seven months later, a communications breakdown within the immigration department led to a senior official denying any knowledge of Zaoui while his colleagues were simultaneously owning up to it. Worse still, a memo was then leaked in which the official lambasted his staff for failing to "lie in unison".

In August, the government's refugee appeals body rejected the SIS's threat assessment, saying it was based on questionable sources gleaned from the internet and news reports. The SIS responded in the traditional manner of spy agencies caught with their pants down: by announcing that it had other, more damning evidence, that was unfortunately too sensitive to release.

What little credibility the original threat assessment retained was demolished in September, when it turned out that the decision had been based on material taken from the website of an American conspiracy theorist who believes the IMF created Aids and the Queen is a drug dealer.

Last month, the judge overseeing the case gave his views on asylum to a New Zealand magazine, saying that "we don't want a lot of people coming in on false passports [that they have] thrown down the loo" and that if it was up to him, Zaoui would be "outski" on the next plane. Questions about judicial objectivity followed.

None of this is to say that Zaoui is necessarily pure as the driven snow. He has been kicked out of Belgium and Switzerland and found guilty of heading a criminal organisation by the Belgian courts. But no one has yet offered a shred of evidence that he poses a threat to New Zealand.

It is a testament to the continuing spirit of toleration in this country that support for Zaoui is gradually spreading beyond the usual suspects of the left. Commentators have for the most part become more willing to believe his word, and those of his lawyers, than the statements put out by the SIS.

Such a situation would be unthinkable in Australia, where no mainstream newspaper would be likely to offer such unqualified support to an asylum seeker - a Muslim one, no less - who had been described by government spooks as a threat to national security.

Nonetheless, even New Zealand's politicians can see the benefit of a spot of populist xenophobia. Just over a fortnight ago a leaflet was sent out by Winston Peters, a leader of the New Zealand First party who has cornered the local market in racist drum-banging.

Unlike Australia's One Nation, New Zealand First has no problems with the country's indigenous population - Winston Peters himself is Maori.

Their beef is mainly with the immigrants from Korea, China and Japan who make up a slim 13% of the population in Auckland, but the Zaoui case provides an excellent excuse for them to turn up the temperature on race.

Under the headline "Whose country is it anyway?" Peters's leaflet rails against Asian immigrants, falsely claiming that hundreds of thousands are coming to New Zealand and blaming them for, among other things, traffic problems in Auckland. These immigrants are, according to Peters, simultaneously poor enough to be leeches on the welfare system, and rich enough to drive up the cost of housing.

It would be easy to dismiss all this as a piece of desperate populism. But, unlike the Australian One Nation party, New Zealand First is not a collapsing political joke: it is the third-biggest party in Wellington's parliament, and until 1999 Mr Peters was the country's deputy prime minister. Barring an electoral miracle, the opposition National party will have to take them on as coalition partners if it is ever to win another election.

To his credit, the National party leader, Don Brash, has dismissed the leaflet as "racist and despicable". A former head of New Zealand's reserve bank, he also pointed out that the country couldn't survive economically without immigration.

But it would be best not to do what Australian politicians did in the mid-1990s, and underestimate the groundswell of popular racism. Outside of Auckland and Wellington, most people seem to associate Asian immigration with problems, rather than benefits; a veteran commentator in the New Zealand Herald described Peters's leaflet as "pretty much spot on", before singing the virtues of racism and warning that Asians were intent on colonising the country.

Popular xenophobia tends to emerge from nowhere, sweeping all before it in a squall of indignation. Perhaps there is something in the water in New Zealand that will always keep it a more tolerant country than its neighbour across the Tasman Sea. But I wouldn't want to bet on it.