A key figure in Sri Lanka’s batting line-up for more than a decade, Samaraweera, 36, rebuilt his career after being shot in a militant attack on his team bus in Pakistan in 2009.
“I was shocked with my omission from the squad against Bangladesh,” he told reporters, adding he had been told by the selectors that they may need him for the tour of Pakistan later this year.
“There was no point in waiting for nine months. I respect the decision of the selectors to go with young players and decided it was the right time for me to retire.”
Samaraweera will, however, play for Worcestershire in English county cricket this year.
He compiled 5,462 runs in 81 Tests at an average of 48.76 with 14 centuries.
He also played 53 one-day internationals, scoring 862 runs at 27.80 with two hundreds.
His form dipped on a recent tour of Australia where he managed just 79 runs in six Test innings, the dismal performance eventually leading to his ouster from the squad against Bangladesh and his retirement.