RIO DE JANEIRO -- The hillside shantytowns here draw attention twice a year: in November, when campaigning politicians labor up the slopes to shake hands and kiss babies, and in the February rainy season, when avalanches send the makeshift cities cascading down.

This season saw nearly 18 inches of rain fall in three weeks -- more than usually falls in half a year -- on this city of 8 million and on the neighboring mountain town of Petropolis.

The toll was 277 confirmed dead, nearly 1,000 injured and 18,000 homeless. Buildings collapsed, cars were swept away like small boats in a rip tide. The damage has soared into hundreds of millions of dollars. Hepatitis and tetanus are spreading; leptospirosis, provoked by parasites that flourish in stagnant waters, is epidemic.

In the favelas, those squatter cities of scrap wood, adobe and sheet metal that harbor more than 1 million, carnival dancers had barely retired their brilliant costumes and floats when the torrents came.

The losses were the largest since storms in 1966 claimed 400 lives. Lately, though, even modest rains have proven deadly. By now the official responses unfold as if by script.

Once more, a president gasped from the window of a helicopter at the city in tatters below and went away promising emergency largesse. Once more, donations to the victims gushed forth, from Sao Paulo to Paris. A pigtailed TV idol handed pigtailed doll replicas of herself to injured children. A soccer star autographed his jersey for a boy in bandages.

And, more insistently, historians and geologists said that political neglect and encroaching poverty had conspired to render this sophisticated metropolis a hostage to the elements.

The first culprits were the 17th- and 18th-century European sugar and coffee barons, who tore away the forests of Rio's magnificent 3,300-foot Tijuca mountain to lay down their plantations. Soon there was no vegetation to absorb and channel off precipitation into stream beds. "By the early 19th century, Rio already began to suffer from drought," said geologist Helio Monteiro Penha of the Federal University here.

It took Dom Pedro II, a conservation-minded emperor, to expel the barons and replant the devastated area. Tijuca withstood the punishment of nature and of man until the late 1950s, when an epic drought in Brazil's Northeast sent up to 300,000 refugees streaming into Rio, and up the mountainsides. Since then, the flood of migrants has never stopped.

With the choice real estate disputed by the wealthy, the poor crowd into danger zones, in flood plains and on denuded slopes. Every year, rains slash deeper into the bared soil, dumping tons of silt in waterways, causing rivers to overflow into the city's streets. Now "people flee the drought in the Northeast only to die in floods in Rio," said Helio Penha.

Rio's perennial drama has been the subject of academic tomes, political debates and sometimes drastic action. One mayor in the 1960s bulldozed the favelas he deemed hazardous, while populists tried to "urbanize" the slums, paving the chaotic streets, distributing property deeds and stringing power lines.

What is missing is a policy of "intelligent urban occupation," according to Jaime Lerner, an architect and former mayor. "The city needs clear zoning rules, strict neighborhood self-inspection and, most of all, a plan to identify where the city can grow."

Four years ago, Leonel Brizola, then governor of the state that embraces Rio, hired Lerner to draw up just such a plan, called Rio 2000, to plot the city's course until the end of the millennium. It included revitalization of the downtown and alternative housing, located not in danger zones but in the vacant lots bordering railways. Lerner suggested the city commission the favelas to collect their own garbage. Currently favela trash accumulates by the ton on hilltops, out of reach of municipal collectors, creating a time bomb for the residents below.

Then came the 1986 election. A new governor from a rival party took over, and Lerner's project died on the drawing boards.