Having barely averted a trip to the junkyard, the car that had "the engine of the future" is back in the spotlight on the shwroom floor.

Mazda's new rotary-engine auto, the RX-7 sports car, is in such demand that dealers have been adding premiums of up to $2,500 to its $7,000 sticker price before delivery to anxious customers. And the comeback of the rotary is reviving the hopes of Mazda's manufacturer, Toyo Kogyo Co. Ltd. of Hiroshima, Japan, that it once again can grab a big slice of the American car market.

But observers say the company will need more than a flashy sports car to regain the sales position it had before the rotary's downfall in 1974.

"They may be able to come back, but it will take them more than a year or two," said Gerald Bengtson, sales planing manager of American Honda Motor Co., importers of Honda automobiles. "And they can't do it around just one car. It's like building a football or basketball team around one superstar. It won't make them instant champions."

But the waiting lists for the RX-7 remind longtime dealers of those heady days of 1971 when the radical Wankel rotary engine caught the eye of American car buyers. Instead of pistons and valves, the rotary uses a triangular rotor turning inside a large oval chamber to generate compression. The firing of gasoline vapor by the spark plugs turns the rotor, and the engine is both peppier and quieter than its reciprocating cousin.

The rotary-powered car became almost a fad in the early 1970s and couldn't be imported fast enough. Salesmen with excited customers reportedly fought over Mazdas when a shipment arrived. At its peak in 1973, Mazda sold 119,000 cars in the United States, nearly all of them with rotary engines. In a few years, the company had come from obscruity to capture fourth place in U.S. sales among foreign auto manufacturers.

Success faded more quickly than it came, when the sudden rise in the price of gasoline made the guzzling rotary a white elephant. In April 1975, Mazda dealers were giving $500 rebates as they tried to unload the 11,000 1974 rotary models left on their lots. Toyo Kogyo lost the yen equivalent of $57.7 million in 1975.

Even a two-year warranty that covered everything, including light bulbs, didn't help, as 1976 U.S. sales fell to a low of 41,000 -- 10th place among importers.

Although the company has continually made piston-engine autos, dealers said the decline of the rotary carried over to its entire line of cars.

"Mazda had a bad reputation with the rotaries," said Jim Baxter, manager of California Mazda agency. "So anything associated with the name Mazda just wasn't going over real big."

Besides getting only about 10 miles to a gallon of fuel in city driving, the earlier rotary engines had minor mechanical problems that, though quickly solved hurt sales. And the Environmental Protection Agency gave the earlier rotaries poor marks for emission control.

Kenichi Yamamoto, Toyo Kogyo's director of research and development and father of the Mazda rotary, said in a recent interview that these problems have long since been solved. Use of a thermal reactor (basically an afterburner) has cut emissions to an acceptable level, he said, and putting the engine in a lighter car has boosted combined city-highway fuel economy to about 21 miles a gallon.

"We've had an unhappy past, both with emission control problems and gas mileage," Yamamoto said. "There was very little discussion of the advantages of the engine. It wasn't packaged right, but the RX-7 is designed just for the rotary. The customer buys the package, not just the engine."

The advantage he's talking about is performance, often measured in the amount of time it takes for a car to go from a standstill to 60 miles an hour. To build favorable publicity for the RX-7, Toyo Kogyo staged a press preview in Japan before the car was introduced. The result was several articles in American car magazines that in general said the RX-7 was both less expensive and faster than the Porsche 924 and Datsun 280Z, the cars it would be competing against in the marketplace.

U.S. dealers said this pre-sale publicity generated hundreds of orders for the car before it was available in May. And despite widespread price gouging, demand has not abated.

"The car was designed to bring customers into the showroom so they could sell other cars," said one competitor. "It's certainly done that."

Sales of the Mazda GLC, a piston-engine car and the only other one now imported by the company, have climbed steadily with the introduction of the RX-7, and total sales this year are up nearly 50 percent from 1977. Dealers say they are alloted RX-7s in proportion to the number of GLCs they sell. Mazda officials say current monthly imports of 3,300 RX-7s will climb to 4,000 a month early this year but won't be stepped up to fully satisfy the demand.

"We don't want to find ourselves in the situation of having too many cars like we did a few years ago," Yamamoto said.

The Japanese auto maker intends to expand its U.S. product base in March with the introduction of a piston-powered sedan that will be priced below the RX-7 and will compete with European luxury imports.

Tsutomu Murai, executive vice president of Toyo Kogyo, said U.S. sales this year will be the second best ever, and total profit should reach the yen equivalent of $83 million, a record. Murai was one of four executives placed in top jobs at Toyo Kogyo in 1976 by Sumitomo Bank Ltd., the company's biggest creditor.

He said the emphasis since then has been on cutting production costs. Total employment of 27,000 is down sharply from its peak of 37,000 just before the 1973-74 rise in the price of oil, yet production for 1978 is estimated to be a record 851,000 cars and trucks, he said

He said the auto maker's debt, the yen equivalent of $1.7 billion a year ago, will be reduced to just under $1 billion this year.

Murai admits that the RX-7 by itself isn't going to sweep U.S. car buyers into Mazdas but points to other actions Toyo Kogyo has taken to help its American image.

He said the never-perfect U.S. sales and service operation has been beefed up, with the auto maker sending three groups of engineers to field-train U.S. mechanics and monitor service performance. And he thinks introduction of the mid-priced sedan will be another plus.