Gary Kasparov, a 22-year-old chess genius from the southern Soviet city of Baku, scored a dazzling, last-minute victory tonight to become the youngest world champion in history.

With 15 minutes left on the clock at the end of the final game of the championship match, Kasparov whisked through a series of moves that seemed to stun defending champion Anatoly Karpov, leaving chess fans aghast and delighted. Karpov, 34, the Soviet who has held the world title for 10 years, resigned after the 42nd move, caught in a trap that chess grandmasters here described as brilliant.

The chess played by Kasparov tonight was so awesome that even his advisers said that they could not understand his high-risk strategy 20 minutes before his victory.

"It was a victory worthy of a champion," said Soviet grandmaster Mark Taimanov. "It was a very complicated struggle from beginning to end -- one of the most beautiful games of this match."

The crowd packed into the 1,500-seat Tchaikovsky concert hall tonight burst into applause twice when the end was clear, but before Karpov conceded.

Security men with walkie-talkies tried in vain to contain the excitement, but when a flushed Karpov finally resigned, offering his hand in defeat, they were swept aside as the crowd got on its feet, clapping and chanting, "Gary, Gary."

As he left the stage, the new champion gave the audience a broad grin, and with an exuberance that has made him the popular favorite, he raised his arms in a victory salute.

In the hall, fans rushed to congratulate Kasparov's mother, Klara, who has attended every game and is considered a key influence on him.

Spontaneous celebrations continued in the lobby of the concert hall, where young people and dark-haired natives of the Soviet Union's various southern republics showed their loyalty by jumping and whooping, kissing and hugging each other.

"Because he is young, because he is more pleasant than the other one," said one exhilarated fan, explaining his support for Kasparov, "and because he is not just a chess player, but an artist."

The dramatic finale was a fitting conclusion to a bitter but well-matched competition that began 14 months ago. Kasparov, the bold young challenger, half-Jewish, half-Armenian, born and raised in the mainly Moslem republic of Azerbaijan, went into his first world championship in September 1984, facing Karpov, the quiet, bland bureaucrat of the Soviet chess establishment.

A rematch is likely between the two. As ex-champion, Karpov can play Kasparov again as early as next year. Their first match, which dragged on for 48 games, of which all but eight were draws, ended last February in a scandal that established Kasparov as a maverick outsider to the closed world of Soviet and international chess.

The second match, started last September, was limited to 24 games. Under the new rules, draws counted a half point for each player, while wins were a full point: Kasparov needed 12 1/2 to win, while Karpov, as defending champion, had only to score 12.

As the second match went into its final rounds, the various rivalries -- personal, political and ethnic -- came to a head. Tensions simmered below the surface as Kasparov's supporters in chess officialdom complained that they were not being treated fairly.

On the chessboard, Kasparov, stocky and physically fit from training at swimming and soccer, came on strong, some said helped by his earlier, five-month bout with Karpov. Karpov, meanwhile, seemed weaker, both physically and psychologically.

After the 19th game, a key point in the match, Kasparov held a two-point lead and many experts thought he was on the verge of capturing the title.

But during the past week, Kasparov's drive for the title seemed to teeter. He yielded a draw in one game where he was considered the favorite and Karpov, staging a valiant comeback, won the 22nd game.

By tonight, the last game of the match, the score was 12-11 for Kasparov. A draw would have put him over the top. The fact that he played the game to a stunning, all-or-nothing victory was considered typical of the bold, challenging style that has made him a favorite among chess fans.

"They played without compromise," said Taimanov.

Playing black, which is often considered a defensive situation, Kasparov went into an unorthodox variation on a familiar pattern. At one point, it involved deliberately sacrificing a pawn, a risk few in the hall understood.

"People are shocked that he is playing such a risky game," said one chess expert. "But he is playing like himself."

The two players' styles of play reflected their different personalities. Karpov, closely tied to the Soviet Union's chess and political establishment, was known for his cautious, sophisticated and technically near-flawless chess, whereas the challenger was known as a risk-taker, more in the mold of his hero, the eccentric American champion Bobby Fischer.

The rivalry between the two men took a personal turn last winter, when, after five months of exhausting play, the president of the International Chess Federation, Florencio Campomanes, a close ally of Karpov, flew to Moscow to cancel the rest of the match.

Campomanes said the decision was taken for the sake of both players, and in Moscow today, he told reporters that the high-level performance of the second match justified his decision.

But Kasparov, who had just won two of his three victories in the series, considered himself robbed, and many experts agreed.

His relations with Campomanes and others in the establishment worsened during the summer when he gave two outspoken interviews to foreign publications, chastising chess officials for their cozy relations with Karpov.

According to chess sources, his outspokenness almost caused him to be disqualified from play. Such a move was considered at a meeting of the Soviet Chess Federation last August, but it was averted when Kasparov came from Baku to Moscow to defend himself, sources said.

To many of his fans, tonight's victory was a vindication for the treatment Kasparov has received in recent monhts. "Justice is done," cried one jubilant supporter at the end of the match.