The 27-year-old Malinga said he would still be available for one-day and Twenty20 internationals but did not want to risk permanently injuring his right knee by playing in the longer version of the game.
"Although I am sufficiently fit to play both ODI and T20 cricket, I have a long-standing degenerative condition in my right knee that needs to be carefully managed," Malinga said in a statement.
"I have carefully considered my options and have decided that not playing test cricket will help me achieve my goal of representing Sri Lanka in the 2012 World Twenty20 and the 2015 World Cup."
Sri Lanka Cricket said it is unaware of Malinga's decision.
Malinga recently made himself unavailable for Sri Lanka for the team's three tests in England this summer, saying he would not be fit enough, but has continued to feature in the lucrative Indian Premier League for Mumbai Indians.
That sparked a club-versus-country debate, with Sri Lanka chief selector Duleep Mendis saying the situation was "awkward" and prefering Malinga to begin a rehabilitation program rather than carry on playing in the IPL.
Malinga said he first sustained damage to his knee while playing in a one-day series in Australia in 2008. He has only played two tests since then, both against India last year.
"I did try to return to test cricket after a three-year absence last year following requests from the team management and the selectors, but it left me unfit nursing severe knee pain for two months," Malinga said.
"I have realized that the heavy workload of test cricket, which requires a fast bowler to be able to bowl more than 15 overs, sometimes on consecutive days, could lead to permanent injury."
Malinga played 30 tests, taking 101 wickets at an average of 33.15 after making his debut in 2004.
He has a much better record in the shorter formats and he starred for Sri Lanka in the team's run to the final of the World Cup this month, where it lost to India.
Malinga has taken 127 wickets in 84 ODIS, at 26.38. In T20 internationals, he has 35 victims in 29 matches.