DETROIT — Nearly all of the major automakers reported steep sales declines for June, but for General Motors, at least, there was consolation: Toyota, its leading international competition, had it worse.

Even Toyota, with its flexible, efficient factories, couldn't make the shift from trucks to cars as quickly as American drivers. Its sales for June shrank 21 percent.

So the Japanese automaker fell short of some analysts' predictions that it would overtake GM as the U.S. sales leader. June sales at GM had a still-dramatic drop of about 18 percent.

The overall market fell 18.3 percent, according to Autodata Corp. It was the worst June for the industry in 17 years, said Jesse Toprak, chief industry analyst for auto information site Edmunds.com, who predicted more misery ahead.

Toprak said automakers simply did not react quickly enough to the staggering rise of gas prices.

"The gas price rise that we've seen from March through June was so fast and so dramatic that even Toyota, which is known to really forecast consumer demand, was caught off guard," he said.

The shrinking market continued its shift toward more fuel-efficient models. Some automakers were caught with too few of the smaller cars.

That includes Toyota Motor Corp., which didn't have enough of its fuel-efficient Prius, Corolla or Yaris cars at dealerships to keep up with demand. Prius sales were hurt by a battery shortage, while sales of the Corolla and Yaris suffered because of plant capacity.

When consumer tastes change as quickly as they have this year, it's tough for automakers to react in a matter of months. Additional workers have to be brought in to factories and trained to build different cars.

Ford has been trying to raise output of the lone factory near Detroit that makes the Focus compact but still couldn't meet demand this month. Both GM and Ford have announced plans for new subcompacts, but it will take at least two years to gear up factories for the new products.

"That just shows the market forces changed extremely fast. No automaker was ready for it," he said.

Only Honda Motor Co., whose lineup is tilted toward smaller and more fuel-efficient cars, reported a sales increase for June — slightly over 1 percent. Honda car sales were up nearly 20 percent, truck sales down 24 percent.

Elsewhere, the picture was far worse. Nissan Motor Co. reported sales off nearly 18 percent. Sales at Ford Motor Co., which still relies on trucks and sport utility vehicles, plunged almost 28 percent. And Chrysler LLC took a huge hit — down nearly 36 percent.

The overall market dropped to about 1.2 million vehicles sold, down more than 266,000 from last June. U.S. car sales were down about 10 percent for the first half of this year.