(CNN) -- South Africa have toppled England from the top of the world Test rankings after clinching a 2-0 series victory on the final day at Lord's.
The Proteas dominated play on day five to win by 51 runs, having won the opening match of the three-Test series by an innings and 12 runs and drawn the second encounter.
The start of the final Test, which England needed to win to stay top of the rankings, was overshadowed by claims that key batsman Kevin Pietersen sent negative texts about his teammates to their South African rivals.
The former national captain, who scored 149 in the second Test, was left out of the squad after refusing to sign a letter confirming he did not send the derogatory messages.
Resuming on Monday at 16-2, the home side struggled to make any significant headway towards the 346 runs required to secure an unlikely victory and salvage the No. 1 ranking, and were 120 runs off the target with just three wickets remaining before the start of the final session.
Ian Bell and James Taylor both fell for four as England crumbled to 45-4, but Jonathan Trott and Jonny Bairstow added 89 for the fifth wicket to revive faint hopes of victory.
Bairstow, called in to replace Pietersen, made 95 in the first innings and he again impressed with a quickfire 54 off 47 deliveries faced in his second knock before being bowled by spinner Imran Tahir.
South Africa-born Trott was the next to go with the score on 146 as he fell to pace bowler Dale Steyn for the second time in the match, on this occasion succumbing to a superb diving catch at second slip by Jacques Kallis as he posted 63 off 159 balls.
Matt Prior, another England player born in South Africa, made a defiant 73 before being the ninth man to fall as he edged a ball from Vernon Philander to captain Graeme Smith.
Philander then dismissed tailender Steve Finn for no score to end with figures of 5-30, and seven wickets for the match.
Smith dedicated the victory to Mark Boucher, the team's former wicketkeeper who was forced to retire from international cricket after suffering a serious eye injury in a warmup match ahead of the series.
"This is a message from all of us," said Smith, who wore a shirt reading "We miss you Bouch."
"He's been part of us for 147 games and this was meant to be his 150th. This victory was for him and for everything he has done for us."
England captain Andrew Strauss, who was reportedly the subject of some of Pietersen's text messages, paid tribute to the tourists and acknowledged his team's struggles in the past year since taking the No. 1 ranking from India.
"South Africa were the better side over the course of the series and thoroughly deserved their victory," he told reporters.
"They were just better than us. I don't look back on our time as number one with a great deal of fondness, as we had some tough times.
"That can be a good thing, though, as Test cricket tests you when you're number one. We've learned a lot and it's a shame to hand it over, but they deserve to be number one and we will come back."
South Africa will next tour Australia for a three-Test series starting in November, while England will go to the sub-continent to take on India again.
Pietersen's future remains in doubt, and he is unlikely to be selected for the World Twenty20 competition starting next month. After being dropped, he was dismissed for no score in a limited-overs match for his county team Surrey.
In a bid to limit damage to his selection hopes, last week he posted a video apology on the internet and later issued a contrite statement following his omission.
"The texts were meant as banter between close friends. I need to rein myself in sometimes," he said.
"I apologize to Straussy and the team for the inappropriate remarks at the press conference and for the texts. I truly didn't mean to cause upset or tension particularly with important games at stake."
The England and Wales Cricket Board (ECB), however, has refused to say whether Pietersen will ever play for England again.
"We are in receipt of Kevin's apology, but further discussions need to take place to establish whether it is possible to regain the trust and mutual respect required to ensure all parties are able to focus on playing cricket and to maintain the unity of purpose that has served us so well in recent years," said ECB managing director Hugh Morris.