LONDON (AP)—Just nine months after returning from a career-threatening knee injury, Rafael Nadal clinched the year-end No. 1 ranking for the third time by beating Stanislas Wawrinka 7-6 (5), 7-6 (6) at the ATP finals on Wednesday.

Nadal, who beat Wawrinka for the 12th time in as many matches, can't be overtaken by No. 2 Novak Djokovic. It's the first time since 2010 that the Spaniard, who returned from a seven-month injury layoff in February, ends the year as the top-ranked player.

''A lot of emotions today, it's the perfect scenario to finally be the year-end number one,'' Nadal said after celebrating with fist pumps and leaps as if he had won the tournament — the only major title missing from his collection.

''Being number one at end of the season is something really difficult as there are some unbelievable competitors out there. But without my team behind me, it would be hard to think about achieving this, especially after what happened last year.''

Nadal advanced to the semifinals of the year-end tournament because of his straight-sets victory over his Swiss opponent.

The Spaniard's season will be remembered as a stunning comeback, during which he captured 10 titles — including two Grand Slams.

Following his defeat in the second round at Wimbledon last year and the extended absence that followed, only the boldest of bookmakers would have bet on Nadal achieving such success in 2013.

When he resumed playing, his left knee was still causing him pain. However, Nadal's confidence grew during a tour of Latin America during which he went 12-1, winning titles at Sao Paulo and Acapulco.

After securing his eighth French Open title, the only real disappointment of the year came at Wimbledon, where he lost to Belgian Steve Darcis in the first round before adding a second US Open title.

He overtook Djokovic for the No. 1 ranking last month in Beijing, where he reached his 13th final of the season.

Nadal beat David Ferrer in his opening match on Tuesday and kept the momentum going against Wawrinka.

After breaking him in the fifth game, he looked in complete control. Raising his game on important points, he erased Wawrinka's two first break points to build a 5-3 lead and looked set for an easy victory.

But the tournament debutant held on as Nadal served for the set, sending a sizzling crosscourt backhand that the top-ranked player returned out of court to earn a third break point. He seized his opportunity, wrongfooting Nadal with a crosscourt forehand.

The tie break was a tense affair. At 5-5, Nadal defended superbly to return a devastating forehand down the line from his opponent, who shanked his next shot. Nadal sealed the set at the first opportunity — as Wawrinka stumbled as he went for an easy volley before smashing his racket on the floor.

Nadal then converted the second of three break points in the fourth game of the second set as Wawrinka sailed a forehand long. But as in the first set, Wawrinka battled his way back into the match, winning his next service game at love before taking Nadal's serve for the second time with a volley that clipped the net cord and bounced over.

Both played more aggressively in the closing stages and held serve until a second tiebreak. Nadal made the most of Wawrinka's mistakes to take a 3-0 lead, but his gritty Swiss opponent took a series of risks with his returns and rallied to reach set point at 6-5. Nadal saw off the danger with a smash, pumping his fist in relief, before sealing victory on his first match point.