Thousands of Cubans took advantage of what appeared to be a diplomatic tiff during the weekend to pour into the Peruvian Embassy compound in Havana to seek asylum.

The massive turnout threatened to create hazardous conditions for those seeking refuge as the supply of food and drink and the sanitary situation were becoming critical, according to reports from Havana and from Lima, the Peruvian capital.

The rush to the embassy apparently was triggered by a chain of events that started Tuesday, when a group of Cubans seeking asylum crashed their bus into the embassy grounds and a police officer was killed in a cross fire. On Friday, Cuban authorities withdrew guards from the outside of the half-acre compound and Saturday they announced that those seeking asylum would be allowed to leave.

Peruvian officials in Lima said 8,000 to 10,000 Cubans had come in by yesterday afternoon, but an Agence France-Presse report from Havana estimated the crowd at 5,000 when the Cuban police finally cordoned off the area.

"There are people in the branches of the trees, on top of the destroyed iron grating and even on the roof of the embassy," a Peruvian spokesman in Lima told news agencies. "We have been informed that there's virtually not enough room for a single other person in our embassy."

Cuba said Saturday that there would be no reprisals against those seeking emigration at the embassy and those on the grounds would be allowed to leave the country if they secured permission from Peru. This offer was also directed at a handful of Cubans who have taken refuge at the Venezuelan Embassy recently.

The announcement, however, specifically denied the exit privileges for those who had entered the foreign embassies by force, apparently referring to about 40 dissidents who have sought refuge in the last year by crashing through embassy gates.

Peru yesterday sought aid from other diplomatic missions in Havana, the United Nations High Commissioner for Refugees and the International Red Cross, according to a statement released in Lima.

Peruvian Foreign Minister Arturo Garcia y Garcia was quoted by United Press International as saying, "Peru alone cannot in the short range mobilize that amount of people. That is why we are seeking international solidarity, but will do everything possible to place them abroad."

Officials in Washington said the United States had not been approached to take some of the refugees, apparently because many Cuban dissidents already are allowed to emigrate here. The United States accepted between 9,000 and 10,000 Cuban emigres since early 1978, one official said. He classified most of them as political prisoners and their families, as well as relatives of Cubans who had already emigrated.

Observers said the announcement by President Fidel Castro's government could be a result of the Cuban belief that Venezuela and Peru encourage dissatisfied Cubans to leave by granting asylum to those who make it into their embassies. By opening the doors to such large numbers, the Cubans appeared to have turned the tables on the two countries, which have long defended the cherished Latin American tradition of political asylum but were not ready to deal with such large numbers of refugees.

A U.S. official expressed surprise at the high number of Cubans that moved into the embassy grounds but said the Cuban decision to let them go was not uprecedented since Cuba has been relatively liberal with exit visas.

Most of those seeking asylum are believed to be relatives of Cuban emigres or those dissatisfied with conditions caused by the failing Cuban economy.

Cuba, in the past, has accused Peru and Venezuela of encouraging acts of violence against embassies in Havana by granting asylum to the Cuban dissidents. Both countries have denied the charges.

Recently, the government assigned the guards to the embassies in Havana by granting asylum to the Cuban dissidents. Both countries have denied the charges.

Recently, the government assigned the guards to the embassies to discourage the flow of Cubans seeking refuge. But after the guard's death last week, Cuba withdrew the forces, apparently in disgust.

Since December, 18 Cubans have forced their way into the Venezuelan Embassy and 23 had taken refuge in Peru's mission. Eighteen Cubans were allowed to leave Havana for Caracas last year after forcing their way to asylum.

Guards continued to be posted around the Venezuelan Embassy throughout the week and no Cubans were reported to have sought asylum there during the weekend.

Officials in Lima said that government supporters gathered outside the embassy compound in Havana, throwing sticks and stones at those seeking asylum and injuring a number of people.