HAVANA, JULY 24 -- For two weeks, a steady stream of Cubans sneaking, barging, breaking, climbing and vaulting into embassies and diplomatic residences here has provoked a diplomatic crisis.

The incidents, ostensibly the work of asylum seekers, and President Fidel Castro's response, have severely damaged Havana's relations with some of its most important trading partners and historical friends at a time when Cuba has lost its major allies in Eastern Europe and can ill afford further diplomatic isolation.

The embassy sit-ins have coincided with a wave of defections in recent weeks by prominent Cubans, including high-level diplomats and a nuclear physicist. It was announced Monday that Arturo Sandoval, an internationally known jazz trumpeter who enjoyed tremendous privileges in Cuba, had defected and is now in Miami.

"These are all symptoms of the same disease," said a Western diplomat. "Fidel doesn't want to compromise on the fundamental nature of the system."

There are still no signs that Castro's rule is on the brink of collapse, nor has anything resembling a viable political opposition been allowed to show its face.

Yet both the embassy invasions and the defections, coming as Cuba's economy continues to slide, are evidence of spreading discontent on this island of 10 million people. In response, Castro has shown his determination to keep that discontent in check even as his own image of invincibility fades.

Castro continues to insist that the Cuban system can be reformed at the margins but not fundamentally altered. He has ruled out any perestroika-like program of economic change and banned even discussion of the existence of political parties other than the Communist.

Indeed, he has continued to warn that in the aftermath of what he calls Eastern Europe's political "disaster," preparations are underway for a draconian austerity program, which he likens to putting the economy on a wartime footing. The program, which would be supervised by the military, would include a halt in key social development programs, Castro has said.

Underlying virtually all of Castro's major pronouncements is an assumption that he will retain absolute control. He has moved to stifle internal dissent and all but crushed a fledgling human rights movement. Many dissidents are already in prison, and 10 more received sentences of up to 15 years last week for what prosectutors called terrorist activity.

The embassy incidents, which began July 9 when five Cubans took refuge in the Czechoslovak mission, followed a sudden exodus of thousands of Albanians to Italy and prompted an immediate sense of crisis in Havana. There were instant comparisons with the 1980 Mariel boat lift, when a wave of asylum requests spun out of control, leading to the departure of 125,000 Cubans to Florida. Many observers say that 10 years after Mariel, conditions are ripe for an even greater exodus.

"In 1980, the economy was still growing and {Cuba} could still get credit internationally," said one diplomat. "Now it's totally different. The hopelessness is prevalent."

To stem such a crisis, Castro apparently decided to take the extraordinary step of sending agents into the embassy to extract the asylum-seekers, diplomats say. According to the envoys, at least 22 of the 44 Cubans who claimed to be seeking asylum since the crisis began are probably working for the Cuban state security apparatus.

They include half of the 18 Cubans who remain in the Spanish Embassy and five who ransacked the apartment of a Czechoslovak diplomat on July 13, diplomats said. The probable agents also include seven who entered the Czechoslovak Embassy July 16, threatened to blow up the premises, briefly held diplomats there hostage and then departed with several other Cubans in tow, including several who probably were genuine asylum seekers, according to diplomats from four Western countries.

The diplomats also say they suspect that one other Cuban, Lazaro Angel Cabrera, who entered the Czechoslovak Embassy July 9 with four other asylum seekers, may have been working with the Cuban Interior Ministry.

"It's a warning for every other embassy and every other asylum seeker," said one diplomat. "But the risks are enormous: He could kill off tourism and investment."

The incidents at the Czechoslovak Embassy and the Czechoslovak diplomat's apartment in Havana also have underscored the extent to which Cuba's relations with one of its most steadfast former East Bloc allies have deteriorated. Most Czechoslovaks, including diplomats, have left Cuba.

In a letter June 22, Czechoslovak President Vaclav Havel, a former dissident who was imprisoned for attacking the Czechoslovak Communist government's human rights record, criticized Cuba's performance on human rights. In an indignant response, Castro accused Havel of ignorance of Cuba's problems.

"Castro's aim here was to pre-empt the whole asylum issue, to head off an Albanian-style asylum move and also to poke it in the eye of Havel," said a Western diplomat. In the process, he said, the crisis has taught embassies that "if they took in asylum cases things would get messy."

Today, 25 Cubans remain holed up in embassies and diplomatic residences in Havana. They include the 18 at the Spanish Embassy, three at the Swiss Embassy and four at the Italian ambassador's residence. In an interview, a Spanish diplomat said he strongly suspected that nine of the 18 Cubans in his embassy were not genuine asylum seekers. He described them as in their twenties and early thirties and physically fit and said they gave inconsistent stories about their jobs and backgrounds.

He said the nine had no access to phones, radio, television or other communication with the outside but would not say whether they had contact with the other Cubans in the embassy who are thought to be genuine asylum seekers. He said nine Spanish special forces policemen had arrived to provide additional security at the embassy.

The crisis has soured Cuba's relations with Spain, one of the island's leading Western trading partners, an important bridge to the West and a major source of tourism and economic aid. Tourism, in particular, is critical to Cuba as a source of hard currency.

Spain has suspended aid programs worth $2.5 million, withdrawn its ambassador and appealed to Cuba to improve its human rights climate. The Cuban Foreign Ministry responded with a furious letter, comparing Spanish Foreign Minister Francisco Fernandez Ordonez to "an anxious colonial overseer."

That Castro was willing to enter a diplomatic row with Spain surprised many observers here because Spain enjoys special status in Cuba, and many Cubans can trace their ancestry there. Castro's father came to Cuba in 1874 from northwest Spain's region of Galicia.

"There's going to be a high cost to lose good relations with a country with which Cuba has had such strong links," said a Spanish diplomat. "But it is apparent that his first priority is to keep control of the internal situation and of public order, and any other consideration is secondary at this point."

The Cubans have accused diplomats from the United States, Canada, West Germany and Czechoslovakia of masterminding the wave of embassy incidents to create chaos in Cuba. All four governments have denied it.

However, the Cubans did not accuse the Spanish of complicity with the alleged scheme. Today, officials from both the Spanish Embassy and the Cuban Foreign Ministry said they were willing to negotiate a resolution to the crisis.

Cuba has said it will not permit any of those taking shelter in the embassies to leave the country. Spain and Italy have said they will not eject the Cubans, and Switzerland has said the three at its embassy would be allowed to stay until Cuba provides assurances that their lives are not in danger.