General Motors Corp. yesterday reported a $2 billion loss for the third quarter, reflecting a decision to shutter a number of facilities -- some permanently -- to reduce production capacity in the face of slumping sales.

The quarterly loss was the worst in U.S. automotive history. The company set aside $2.1 billion for the plant closings; without the reserve, the company would have posted a small third-quarter profit.

By tailoring capacity to demand -- even when it means a huge write-off -- car companies stand a better chance of making more money in the long run, analysts said.

Analysts immediately applauded the plant closings. They have long argued that GM is a major contributor to the overcapacity in the North American auto industry that has forced car companies to spend billions of dollars in rebates and other incentives to get people to buy their products.

"Wall Street sees this as a good thing," said Harvey E. Heinbach, vice president in charge of the automotive group at Merrill Lynch & Co. in New York. "It's clear to everyone that GM has been operating with too much capacity relative to its volume."

GM has been operating at about 75 percent plant capacity, according to some sources, in a market increasingly crowded with foreign car companies producing on U.S. soil. Americans are expected to buy 14.1 million cars and trucks in 1990, down from 14.8 million purchased a year earlier.

GM had the capacity to supply 50 percent of the market, but the company is struggling to hold on to a 35 percent share.

"This is a financial move that's been long overdue," said David Cole, director of the office for the study of automotive transportation at the University of Michigan.

In effect, Cole said, GM is simply "legitimizing" what in fact had already occurred with the four plants that will be shuttered permanently. Under the terms of its recently expired contract with the United Auto Workers union, GM could not close plants unless it proved that they were no longer economically viable. So, instead of closing those plants -- effectively writing them off the books -- GM "idled" them.

GM announced yesterday that the four plants it had idled would be permanently closed and said it would consolidate five parts distribution centers into one. The new GM contract with the UAW allows the closings and leaves open the door for other closings if economic conditions do not improve.

The four closed assembly plants are in Framingham, Mass., Lakewood, Ga., Pontiac, Mich., and Leeds, Mo., with a total of 6,500 people currently on their payrolls.

Other GM facility closings, including some warehouses and parts operations, will be announced over the next three years, GM officials said.

GM's minivan plant in Baltimore, which employs 3,500 hourly workers, is not expected to be involved in future closings.

Without the reserve for the closings, GM made $109 million, 79 percent less than last year's third quarter. In last year's quarter, GM earned $517 million.

GM said its sales during the quarter totaled a record $30.8 billion, compared with $28.8 billion in the same period of 1989.

For the first nine months of the year, GM lost $369 million on revenue of $94.8 billion. In the same period of 1989, it earned $3.5 billion on revenue of $95.6 billion.

GM's third-quarter performance means that the nation's three largest vehicle manufacturers -- GM, Ford and Chrysler -- dropped $2.1 billion in earnings in the period.

Chrysler Corp., which lost $214 million during the quarter, said its earnings were hurt by the temporary shutdown of its minivan plants for model changeovers.

Ford Motor Co. reported a $101.7 million profit for the quarter. But that showing was 78.7 percent below the $477.1 million the company earned in the same period last year.

All three companies said their earnings were hurt by shaky U.S. and foreign economies.

GM stock closed yesterday at $36.75, up 12 1/2 cents. Ford closed at $27.87 1/2, up 25 cents, and Chrysler at $11, down 12 1/2 cents.