With three people dead from a rare outbreak of St. Louis encephalitis and the confirmed spread of the infection to separate parts of the city, Mayor Rudolph W. Giuliani today ordered health officials to spray every borough with insecticide.

Health workers in helicopters and trucks will spray the insecticide Malathion across the city of 7 million in the coming weeks, officials said, to try to reduce the number of mosquitoes, which spread the viral illness.

When the early cases first were detected last week in Queens, Malathion spraying initially was focused there and in the Bronx. But with the confirmation of an encephalitis case in Brooklyn, city officials--assisted by the Atlanta-based federal Centers for Disease Control and Prevention--decided to take more aggressive action.

"By the time we are finished we will spray the entire city," Giuliani said at a news conference. "The information we received is that there is a possibility that if you don't continue to spray, the whole thing can start up again."

St. Louis encephalitis, named for the city where it was first discovered in 1933, is spread when mosquitoes pick up the virus that causes the disease from birds and pass it on to humans when they bite them, said John Roehrig, a CDC virologist. It is not spread from person to person and cannot be passed back to the mosquitoes by infected humans.

By killing the mosquitoes "on the wing, you can break the transmission cycle, which is why we spray," said Roehrig.

Symptoms emerge within two weeks and range from slight fever or headache to tremors, convulsions, swelling of the brain and death in 5 percent to 15 percent of cases. The elderly tend to be most susceptible. All three people who have died from the illness in New York were elderly.

In addition to the deaths, there have been six additional confirmed cases and 60 more were under investigation, said Sandra Mullin, associate city health commission.

To avoid panic, city health officials have tried to assure residents that very few mosquitoes actually carry the virus. Still, officials have urged New Yorkers to wear shirts, socks, long pants and mosquito repellent when outdoors, especially in the dusk to dawn hours when mosquitoes are most active.

"We believe we are taking aggressive steps," Mullin said. "We're trying to minimize the threat."

While individual cases of the disease previously have been reported in New York City, this is the first outbreak of the St. Louis strain in the state. The last time a case was reported here was in 1978. Before that, eight cases emerged in New York as part of a 1974-77 national outbreak, when 2,507 cases were confirmed throughout a broad region of the United States centered on the Mississippi River Valley.

The St. Louis viral outbreak is one of two health problems to hit New York state simultaneously. The state is also experiencing its largest outbreak ever of the E. coli bacteria. So far, nearly 300 people have sought hospital treatment for E. coli and a 3-year-old girl has died. All of them were visitors to a county fair in the Albany area at the end of August. Health authorities suspect rainwater runoff bearing cow feces may have contaminated an underground aquifer.