AB de Villiers has stepped down as South Africa's Test captain with immediate effect and has been ruled out of the three Tests against Sri Lanka as he continues to recover from elbow surgery. De Villiers endorsed his stand-in, Faf du Plessis, to take over permanently and the CSA board have confirmed du Plessis' appointment.

"The interests of the team must always outweigh the interests of any individual, including me," de Villiers said. "It was a fantastic honour for me to be asked to captain the Test side but I have missed two series and I am still in doubt for the upcoming series against Sri Lanka. Following the squad's outstanding performances in Australia, it is clearly in the greater interests of the team that Faf du Plessis should be confirmed as the permanent Test captain."

De Villiers has been out of action since the Caribbean Premier League in July and was expected to be fit for the Sri Lanka Tests but still needs another three to four weeks before being declared fully fit. He will target the ODIs later in January, a format in which he remains captain, for a comeback.

De Villiers had surgery on his left elbow in early October, after initially adopting a conservative approach to recovery, and his surgeon was aiming for a three-month rehabilitation period. De Villiers tried to push that forward and was even talking about a comeback in November's Adelaide Test but only had his first net session last Tuesday. He has been practicing with his franchise, Titans, and had hoped to turn out for them in the ongoing domestic T20 competition but CSA's medical committee did not give him clearance to play. He has also been instructed not to play in Friday's final.

"AB's left elbow is much improved but is still regaining the last few degrees of straightening. Fitness to play requires full range of elbow movement and this may take another 3-4 weeks to achieve," Mohammed Moosajee, South Africa's team manager, said.

De Villiers' unavailability means he would not have captained South Africa since he was named permanent Test captain in February, after taking over from Hashim Amla in the middle of the home series against England. South Africa lost one Test and won one under de Villiers. In his absence, du Plessis led the team to a 1-0 Test series win over New Zealand, a 5-0 ODI whitewash over Australia at home and a 2-1 Test series win in Australia and was widely praised for his leadership skills.

Despite calls for him to stay on, du Plessis remained committed to being a deputy and said he was "100% behind" de Villiers, who also enjoyed the support of the convener of selectors Linda Zondi and premier fast bowler Dale Steyn. Both were quoted in these pages as saying they believed de Villiers was the man for the job, although they noted that du Plessis could not be ignored.

But du Plessis is also under scrutiny because he too may be unavailable for the first Test against Sri Lanka, depending on the outcome of his ball-tampering appeal. Du Plessis was found guilty of breaching the code of conduct in relation to changing the condition of the ball after being caught shining the ball with saliva that also come into contact with a mint during the Hobart Test. He was fined 100% of his match fee but escaped a suspension. He is appealing the verdict and runs the risk of a one-match ban at the judicial commissioner's discretion.

The odds appear stacked against du Plessis after the MCC Committee meeting in Mumbai, where it was decided the body would not recommend any changes to the ball-tampering law, believed it to be clear despite CSA's assertion that the definition of "artificial substance" needed clarity and John Stephenson, MCC's head of cricket, who sat during du Plessis' original hearing, said he had "flagrantly contravened the law". ESPNcricinfo has learned that du Plessis has no intention of withdrawing the appeal. The hearing will take place on December 19, a week before the Test.

In de Villiers' absence, South Africa will also be looking for a reserve batsman. Rilee Rossouw traveled in that capacity to Australia but cannot be considered because he is nursing a foot injury that will sideline him for up to six weeks. Omphile Ramela, who will captain a South African Invitation XI against the touring Sri Lankans, could come into contention. Alternatively, the former Under-19 World Cup-winning captain Aiden Markram, who has been in fine form for Titans, may be considered.

Firdose Moonda is ESPNcricinfo's South Africa correspondent