A fire Monday gutted warehouses holding many of the elaborate, feather-and-sequin costumes and extravagant floats for Rio's Carnival parade, destroying the dreams and hard work of thousands of mostly poor Brazilians who toil year-round to stage one of world's most spectacular celebrations.

Seamstresses, set designers and musicians watched in tears as firefighters struggled to control the blaze that raged through four warehouses. The fire devoured about 8,400 outfits and the ornate sets built each year in the battle to be the city's top samba group.

Three hours into the early-morning blaze, the flames were controlled and 10 warehouses were unscathed, but some of the top contenders and up-and-comers in next month's Carnival parade were knocked out of the competition.

"Do you know what it feels like to work all day, into the night, to make this happen, and then this?" asked Graziela Goncalves Carvalho, a seamstress with Uniao da Ilha do Governador, one of the groups that appeared to have suffered heavy losses. "It's over. There's nothing. This Carnival is over for us."

Carnival is a time when Rio's residents and more than 700,000 visitors pour into the streets for a cathartic, nearly weeklong party where order is subverted and the poorest climb the highest floats dressed scantily in glitter and feathers, parading before the eyes of the world. The revelry culminates in the two-day competitive parade of the elite groups, and ends on Ash Wednesday, when order is restored.

After the fire, many of the participants spoke of pulling together to make sure everyone had something to wear, but with just a month left before the March 6 start of the competition, there is no way to replace the labor-intensive sets. To cariocas, as the people of Rio are known, the destruction was heartbreaking.

"We'd been here 24 hours a day. We were in it to win this year," said Moacir da Silva Pinto, the head of Academicos do Grande Rio's approximately 300-strong percussion section. The percussionists' costumes, which were being kept in the group's home base in the town of Duque de Caxias, were the only ones saved.

Portela, founded in 1923 and one of the city's most traditional organizations, holds 21 championship titles. About 2,800 of its costumes and several sets went up in flames.

Academicos do Grande Rio, one of the newest groups to make it into the top samba league, lost nearly all of its 3,000-plus costumes and all eight of its floats — a combined investment of $5.5 million — plus all the infrastructure it relied on, including computers and workshop machinery, said spokesman Avelino Ribeiro.

About 7,000 people worked for about eight months to pull it all together, he said. But the group will make an appearance, in spite of the huge setback, he said.

"There are a lot of people who spend the year dreaming and working for this, for their moment to go out there and shine," he said. "You can't take that away from them. The material things are gone, but we still have a samba to sing."

The four-story warehouses were extensively damaged, with two of them collapsing internally, according to firefighters. The cause of the fire was under investigation. The warehouses have a sprinkler system, but it wasn't clear whether it worked.

Rio Mayor Eduardo Paes, who plays percussion with Portela, promised the city would help the groups recover and vowed that the Carnival parades would go on.

"These people will put on a great Carnival and will show the energy and the optimism that Rio has," he said.

Paes has no control over the independent samba competition, but he said he hopes that groups hit by the fire are not demoted. Under a soccer-style league system, low-scoring samba groups are dropped into a lesser league for the next year.

"They won't be in any condition to compete," Paes said of the most damaged groups.

Still, many were already trying to bounce back.

"I've cried a lot over this, and now it's time to think about what can be saved," Roberto Szaniecki, the theme developer for Portela, said as he hugged friends. "But I want to make this clear: We're going to get out there. We've got a Carnival to put on."