Magnus Carlsen, a twenty-year-old Norwegian, first rose to No. 1 in the global chess rankings last year. Photograph by Platon

In many ways, tournament chess is still played very much as it was a century ago. Players land their pieces with the delicate thump of baize on wood, then jot their moves on scoresheets and tap the clock forcefully, or gently, depending on the mood they wish to communicate to their opponents. Flanking attendants, called arbiters, make sure that nobody cheats. It’s still quiet enough at a tournament that, among the spectators, you can hear your neighbors’ breathing. But the game has changed in at least one fundamental respect: it is now monitored, and even shaped, by computers. Chess pieces are embedded with magnetic sensors that transmit their location on the board to a computer, which relays this information to the Internet. Online, chess programs provide running commentary, evaluating which player is ahead and whether the move he or she is making is brilliant or a blunder. In a modern tournament, just about the only people who don’t know precisely how well they are doing are the players.

But by the sixth round of the London Chess Classic, in December, Magnus Carlsen, the Norwegian phenom, knew that he was behind. If he lost the game, having already been defeated in two earlier ones, he would probably lose the tournament. He was No. 2 in the world rankings, and a victory would give him a good shot at recovering the top spot; he had played inconsistently in recent months, falling from No. 1. There was talk that he was distracted, underprepared, and overexposed. Chess players trying to get out of trouble act a lot like students taking an exam that they haven’t studied for. Carlsen, who had turned twenty just two weeks earlier, often gives off a vibe of someone who is too cool to do his homework, but now he looked a bit panicked. He cupped his head in his hands, rocked his body, and stared at the board, trying to reboot his brain. At one point, it took him twenty-seven minutes to move a piece.

Carlsen’s problems had begun on his second move. Playing black, he had sent out his queen-side knight beyond his pawns—an unusual decision, given that his opponent, the thirty-five-year-old Russian champion Vladimir Kramnik, had already placed two white pawns in the center of the board. So Kramnik had a nice line of pawns where they would do the most good, and Carlsen had a poorly placed piece that threatened to block any attack he might want to mount. A database of nearly five million games indicated that, when these moves were made, white was twice as likely to win as black; Carlsen was already at a significant disadvantage.

Kramnik, one of the last players trained by the old Soviet chess machine, was eerily steady before the board—at times nearly motionless. Carlsen’s eyelids fluttered in a trance of concentration. He looked boyish in a crisp white shirt and a pair of slim-fit pants that had been given to him by G-Star RAW, the Dutch fashion company, with which he has an endorsement deal.

On the eleventh move, Kramnik traded a knight for one of Carlsen’s bishops—an exchange that Kramnik loves. Kramnik’s game is formidable, and his confidence in the endgame is particularly admired. Carlsen, who is largely self-taught, can play various styles; most often, he works toward gaining over-all control of the board, instead of trying to capture prized pieces. The Russian champion Garry Kasparov describes Carlsen’s style as “strangling pressure, not direct hits.”

Kramnik and Carlsen traded queens, then a pair of rooks. With many of the high-value pieces off the board, the real contest began: the march of the pawns. While Carlsen had been experimenting with his knight, Kramnik had been able to wipe out Carlsen’s center pawns and push his own forward. When a pawn reaches the opposite end of the board, it becomes any piece the player wants, usually a queen. Computer programs now gave Kramnik a commanding advantage. Carlsen had to forfeit his knight to stave off Kramnik’s pawns.

Meanwhile, west of London, Kasparov, who had flown from Moscow to sign autographs at the competition, landed at Heathrow. He turned on his smartphone, examined the game’s positions on the screen, and pronounced Carlsen’s situation “impossible.” Kasparov trained Carlsen for most of last year; Carlsen found him too intense, and ended the arrangement. Kasparov still seems to look out for Carlsen, though, as if worried about a careless nephew.

Chess is played on the board and in the head. As the game continued, Carlsen skirted disaster again and again, and Kramnik’s confidence appeared to fray. After taking Carlsen’s knight, Kramnik could have reasonably expected a quick win, and now it was clear that he’d have to settle for a slow one. Kramnik is said to resent the attention that Carlsen gets, and to take special pleasure in beating him. It must particularly rankle Kramnik when Carlsen adopts a blasé pose—declaring, for example, that losing at Monopoly upsets him more than losing at chess. Carlsen’s dislike of Kramnik might be even stronger. He blames his former tutor Kasparov, whom Kramnik dethroned in 2000: “Kasparov really hates Kramnik. And so by listening to Kasparov . . . it’s really hard not to get some of these thoughts myself.”

Kramnik kept advancing, and Carlsen stayed one step ahead of him. Kramnik drank his tea; Carlsen sipped orange juice. Carlsen managed to move a pawn down the board, forcing Kramnik to send his bishop to block it. On the sixty-second move, more than six hours after the game started, Kramnik erred. He likes to clean up the board before finishing off his opponent, and so he initiated an exchange of knights and rooks when he ought to have dealt with Carlsen’s pawn.

The two players were now down to only eight pieces: their kings, five pawns, and Kramnik’s stuck bishop. The computer programs still favored Kramnik, but they do not take into account momentum and fatigue; complex endgames confuse them. (Kasparov, who had just arrived at the tournament, looked at the game on a large screen in the V.I.P. lounge and said, “The computer is useless.”)

Eight moves later, Kramnik had a chance to make a move that would soon lead to checkmate—the computer programs saw it and Carlsen saw it.

Kramnik did not. He moved his king to the side. Carlsen immediately boxed it in with his own. Kramnik tested the boundaries of the prison, but he could not get out. The new reality dawned on him; the computer programs now called the game even. The two players jockeyed. Kramnik assayed with his bishop, and Carlsen countered with his king. They did this three times, resulting in an automatic draw.

Customarily, the players go from the auditorium to a nearby “analysis room,” where they discuss their game with the tournament’s commentators. When Carlsen ambled in, people put down their phones and laptops and applauded. His recovery had been more dramatic than many of his victories. Kasparov was amazed. “It happens,” he said, happily. Carlsen, with a lopsided grin, sat down to discuss the game. Kramnik never showed up. I saw his pretty wife rushing toward an exit, as if the building were on fire. Later that night, Carlsen sent out a tweet: “Good thing I didn’t resign.”