By Paulo Prada

RIO DE JANEIRO (Reuters) - Drug traffickers in Rio de Janeiro ordered shops closed in one of its biggest slums early Thursday, defying efforts to restore order to the city's vast shantytowns and renewing safety concerns in Brazil as it prepares to host the World Cup and Olympics.

Shops were shuttered and more than 5,400 children were turned away from school Thursday morning after traffickers, shouting from motorcycles, ordered a curfew following a shootout with police late Wednesday that killed a drug dealer.

City and state authorities said they suspended classes at four schools and six day-care centers as a precaution.

Such scenes used to be common in Rio, Brazil's second-biggest city and a metropolitan area that is home to nearly 12 million people. But the city has made huge efforts to weed out criminal gangs that long ruled the favelas, as the slums are known, before next year's World Cup and the 2016 Olympics.

Although Thursday's events were limited to the area around the Complexo do Alemao, a huge series of shanties between the city center and its international airport, they came as Brazil is grappling with a resurgence of crime in other cities, too.

In Sao Paulo, the country's biggest city and business capital, authorities are struggling with a crack epidemic and turf wars between police and criminal gangs.

"This is a war, a 24-hour struggle, across the entire country," Geraldo Alckmin, the governor of the state of Sao Paulo, said in a televised interview Wednesday.

His comments came as the state unveiled a series of measures, including new technology and pay incentives, for Sao Paulo police to meet ambitious new targets in crime reduction.

In Rio, officials said Thursday's curfew was an effort by drug traffickers to revive the lawless slum culture in which they dictate everything from shop hours to permission for non-residents to enter and exit their neighborhoods. "This is another expression of discontent by a few recalcitrant drug traffickers," Paulo Henrique Moraes, the colonel in charge of security in the Complexo do Alemao, said on local radio.

A TENUOUS PROCESS

But the episode also illustrates the tenuous nature of Rio's campaign to "pacify" favelas, a process that involves a military-style invasion of targeted slums followed by continued occupation by police forces. The effort comes as Rio gears up for the 2014 World Cup, which it will host with 11 other Brazilian cities, and the 2016 Olympics, which will be held in Rio alone.

Although authorities have displaced drug gangs from dozens of the slums, especially in wealthy tourist areas and portions of the city being prepared for the big events, many favelas remain unruly. The Complexo do Alemao, for instance, still harbors traffickers and other criminals even though the slum has been occupied since late 2010.

Residents in Rio's outskirts, meanwhile, complain that improvements in some areas have only move problems to poorer neighborhoods. Although crime has decreased in wealthy districts along the city's scenic waterfront, violence has surged in dense inland suburbs nearby.

Elsewhere, growing drug problems and turf wars have begun to plague locales long considered safer than Rio.

During the first three months of the year, the state of Sao Paulo, a populous industrial region around the city of the same name, reported 86,860 violent crimes - 3 percent higher than a year ago and 11 percent more than in the first quarter of 2010.

Alckmin, a former presidential candidate and a leader of the opposition to Brazil's ruling Workers' Party, on Wednesday criticized the federal government for its failure to control a burgeoning drug trade, arms trafficking and other factors that have fueled the increase in crime.

Despite steady economic growth for much of the past decade, Brazil, Latin America's biggest country, still suffers from huge income gaps and social inequality. Lax law enforcement and a slow and overburdened judicial system, the problems make parts of Brazil as violent as some countries at civil war.

Grisly episodes in recent months have made global headlines and shocked residents across Brazil. In late April, a Sao Paulo dentist was burned to death by robbers who were upset she had only petty cash when they held up her clinic. A month earlier, an American student was raped and her French boyfriend beaten when they hailed one of the vans commonly used for public transportation in Rio.

(Reporting by Paulo Prada; Editing by Bill Trott)