Swooping past all 18 of his rivals, Gato del Sol won the Kentucky Derby today.

Ordinarily such a come-from-behind performance might be the stuff of which legends are made. But the upset by this 21-to-1 shot instead confirmed what a mediocre group of horses were behind him, and suggested strongly that the best 3-year-old in America was standing in a stall at Pimlico this afternoon.

Gato del Sol had not won a race in nearly eight months and last week, in the Blue Grass Stakes at Keeneland, he had been soundly beaten by Linkage, whose trainer bypassed Churchill Downs and went back home to Maryland. But Gato del Sol did have one important virtue that was evident with the benefit of hindsight. He had the ability to negotiate 1 1/4 miles--which he did in the indifferent time of 2:02 2/5--while his principal rivals didn't.

So while the two favorites, Air Forbes Won and El Baba, were foundering in the last eighth of a mile, Gato del Sol drove outside them to score a 2 1/2-length victory over Laser Light, another longshot who hadn't won a race all year. Reinvested finished third.

Where Gato del Sol goes from here is uncertain. Trainer Eddie Gregson said before and after the race that he would not race in the Preakness.

For jockey Eddie Delahoussaye and Gregson, there was almost no need to plot strategy today. Their horse's running style is immutable, and the No. 18 post position virtually dictated that he would be making his move out the outside. Still, Gregson was somewhat optimistic. A former student of history at Stanford, he had studied the 107-year history of this race and concluded that horses like his usually perform well as long as there is an honest pace in front of them. He got his wish.

After the 19 horses broke from the gate, six of them raced abreast of each other to the first turn. The pace wasn't suicidally fast, but the horses who were parked wide at the turn--notably Muttering and Star Gallant--weren't helped at all by their position. Meanwhile, Delahoussaye had steered his last-place mount toward the inside to save some ground.

Cupecoy's Joy, the only filly in the field, sprinted clear on the backstretch, with El Baba and Air Forbes won stalking her. The jockeys on the two favorites could scarcely believe their good fortune. They had emerged from the pack in ideal position, without another horse in their way. In from of them was a faint-hearted speedster; behind them there was chaos. One of the riders in the pack, Miguel Rivera on Royal Roberto said, "It was like running bumper cars. This must be the craziest race in the world."

While the leaders were counting their blessings, Delahoussaye was surveying the great mass of horseflesh in front of him and recalling a history lesson of his own. "I remembered last year," he said, "when I rode Woodchopper and I got trapped inside and couldn't get out. I figured I'd be better off losing a little ground to stay in the clear. I figured the owners might scream at me for losing that much ground, but I'd rather lose ground than get stopped again." Delahoussaye took his horse wider than anyone on the backstretch and started passing his rivals with alacrity.

But still, the Derby seemed to belong either to Air Forbes Won, the undefeated 5-to-2 favorite, or El Baba, the 3-to-1 second choice. When Cupecoy's Joy began to weaken on the turn, they both moved up outside her to challenge for the lead. Then, suddenly, Gato del Sol came flying five horses wide around the turn and, Delahoussaye said, "I thought I was going to win it." He didn't know that Reinvested, a colt whose only prior claim to fame was winning the Budweiser Derby at Tampa Bay Downs, was making a strong move behind him. With an eighth of a mile to go, Gato del Sol had collared the favorites as Reinvested moved abreast of him.

And at that point, the horses in this race performed in a way that might be savored by students of thoroughbred pedigrees, if not by the people in the crowd of 141,009 who had bet $5 million largely on the basis of the horses' prior performances at a mile and one eighth.

Many of the horses looked as if they were running into an invisible wall--a barrier made of their own genetic limitations. Air Forbes Won tired to finish seventh. El Baba--of whom the pedigree pundits were especially dubious--dropped back to 11th. Reinvested, who had been making such a strong move in the early stretch, stopped accelerating in the final furlong, enabling Laser Light to catch him for second place. And Gato del Sol, a son of the long-winded Cougar II, kept on running right into the history books.

He earned $428,850 for his owners, Arthur Hancock III and Leone J. Peters, and returned his backers here $44.40, $19 and $9.40. Laser Light paid $17 and $9.20, and Reinvested, part of the mutuel field, paid $4.40 to show.

Gato del Sol had not looked like a budding Derby winner during much of his career on the West Coast. As a 2-year-old, he won only one maiden race and one stake, the Del Mar Futurity. This winter he was running against the best 3-year-olds at Santa Anita, but his stretch runs on those speed-favoring tracks always fell short. Gregson thought he would do better on a different type of racing surface and brought him to Keeneland for the Blue Grass Stakes, but in that race, Delahoussaye said, "There was no speed and he was up close early; that's not his style." He finished 5 1/2 lengths behind Linkage.

If Gregson indeed holds Gato del Sol out of the Preakness, he won't have the chance to confront Linkage again and avenge his loss in the Blue Grass. In a racing season which has been singularly devoid of great drama, that nonconfrontation almost figures to happen.