Since the Middle Ages, Amsterdam has been a haven for rebels and refugees. Considered by many to be the most tolerant city in Europe, it has welcomed Huguenots fleeing the French, Jews fleeing pogroms and flower children fleeing convention.

But now, Amsterdam is getting fed up. Grappling with the latter-day urban problems of rising crime, an aggressive army of squatters, a high concentration of heroin addicts and 19 percent unemployment, the city's residents are growing uncharacteristically surly.

"A lot of my nice feelings have just drifted out the window," says Lucky Belder, a 24-year-old art history student who has lived most of her life in the Zeedijk quarter, now the gathering place for one of Europe's largest populations of heroin dealers and users. The entrance to her building is occasionally used as a shooting gallery, and three junkies turned up dead there last year. All of the 10 apartments in her building except hers (on the top floor) have been broken into.

"I used to be very sorry for these people, and tried to help them, to understand them, but now it's just too much," she said.

The new mood was reflected two months ago in the appointment of a new mayor, Ed van Thijn, 49, by Queen Beatrix. A staunch socialist, van Thijn does not like to be described as a law-and-order man, but his inaugural speech was devoted almost entirely to that theme. As interior minister in 1981-82, he had a reputation for making quick and firm decisions.

Already, van Thijn has taken steps to make the police force more effective. And he made clear in a recent interview that he would not hesitate to use force if the city's angry squatters shunned a diplomatic solution to Amsterdam's perennial housing shortage.

The mayor says the city's 3,400 policemen just aren't enough to handle a population of 700,000 and a crime rate that has jumped 34 percent since 1979. Because his budget is restricted by the central government, he is taking police officers from behind their desks and putting them back on the streets.

To attack drug-related crime, van Thijn has doubled the drug squad to 64 with the goal of nabbing the big heroin dealers.

But he also is determined to end the Zeedijk quarter's role as a "free zones for heroin users." He has given all policemen there the authority to scatter groups that look threatening and to ban any suspected criminal from the neighborhood for 24 hours. In Dutch jurisprudence, which is acutely sensitive to individual rights, "this goes very far," van Thijn said.

In this city, however, law and order are not what they are in, say, Philadelphia or Washington. As part of their campaign against drug abuse, for instance, city leaders have proposed distributing heroin free to a few hundred seriously afflicted addicts. The addict's dose of heroin would be prescribed by his doctor, who would examine him at each visit and collaborate with a social worker on the case. The hope is that the addict, freed from his obsessive search for the drug and removed occasionally from his milieu, could be cured or at least protected from the worst effects of his addiction.

The proposal has its critics. Dr. Martien Kooyman, director of a drug and alcohol rehabilitation center here, charges that the city is motivated by the desire to stop drug-related crime, not by a concern for addicts. They are better served by intense, drug-free therapy, he says.

To Lucky Belder, the idea is yet another example of the "repressive tolerance" that has turned her neighborhood into a nightmare of "people shooting up in the streets, dying in the streets, needles on the floor." She says some people in Zeedijk are so exasperated that they talk about forming militias and taking the law into their own hands.

Such impulses are almost heretical in a city that for centuries has gracefully played host to the heretics and fugitives of the day--from Rene Descartes to Anne Frank.

Amsterdam still is able to resolve, with the civilized permissiveness that is peculiar to the Dutch, many of the tensions that tear apart other cities. There have been no race riots, even though the balance between the Dutch and ethnic minorities in Amsterdam is shifting very rapidly. About 30,000 immigrants settle in the city every year, while 40,000 Dutch residents move out.

The one group that has managed to exhaust the city's unusual patience is the squatters, who have rocked the streets with riots during the past three years. Since 1965, they have occupied vacant buildings out of a desperate need for housing and as a protest against the city's inability to provide it. At first, Amsterdam residents sympathized with them. When they became organized and vocal, they were admired as urban Robin Hoods whose political courage had forced the city to confront its responsibilities.

But when some of the city's 8,000 squatters began using violence to make their case three years ago, they galvanized the protective Dutch instinct for democracy.

"People here are used to dialogue, to negotiations, to endless bargaining processes," van Thijn said. "The large majority of the population of Amsterdam is fed up with the squatters' kind of methods."

In 1980, the squatters rampaged regularly through the city, occupied and sacked the housing distribution office, vandalized buildings and construction sites, pulled down the statue of a legendary alderman and even spoiled the coronation of Beatrix. On that spring day, they attacked police horses with razor blades on strings.

For many political observers, a major turning point came after a two-day clash last October when Fred Polak, then mayor of Amsterdam, declared a state of emergency and gave police sweeping powers of arrest. Polak was initially denounced by the press and the city's elected leaders, but as the squatters kept up their violent protests, public opinion began to swing in his favor.

In these stormy conditions, the city has been scrambling to solve its housing problem. From 1980 to 1981, the number of units built more than doubled, from 1,853 to 4,062. This year, 7,000 are under construction, yet the need for more is still great.

Perhaps the only citizens of Amsterdam who don't share the new grumpy mood are the business leaders. Despite the squatter demonstrations, tourism, the city's second largest source of income, has risen about 22 percent since 1980. And businessmen feel that after more than a decade, town hall officials are finally listening to them.

Bob Luyken, managing director of the city's tourism office, said the city realized five years ago that it had no choice. Under the pressure of a mild recession, it had to cope with the consequences of the departure of businesses and middle-class residents for the suburbs since the early 1970s.

Business leaders say that since 1978, Amsterdam's leaders have made efforts to boost the city's economy by offering prime industrial property at low prices, encouraging the construction of parking lots, promoting investment (more than $168 million in the inner-city since 1981) and persuading departing businesses like Algemene Bank Nederland, the Netherlands' largest bank, to stay.

"Profit isn't such a dirty word in Amsterdam as it used to be," says an American resident.