Chandimal had served as Mathews' deputy and led the T20 team in the past, while Tharanga led the ODI team when Mathews had been injured.
Speaking at the press conference to announce the new captains, Mathews, who quit following the 3-2 ODI defeat at home to Zimbabwe, said: "Yes, there have been significant poor performances, and I'm humble enough to accept it. In the past also there were instances where I wanted to step down but I didn't want to let the team down at that time, mainly because there were no replacements. The team's interests supercede my personal interests.
"There were two things working in my mind. The first is whether this was the right time considering the team. My honest opinion is that there are candidates who can take over the reins. I'm pretty sure that they will be more successful and better captains than me. I also wanted to give my successor enough time until the World Cup, to build up a team. Those were the main reasons for me to step down."
Mathews said that although he was disappointed with Sri Lanka's results in 2017, he resigns having given his best to the job.
"I have at all times played in the exclusive interest of Sri Lankan cricket, and have not at any time compromised my national duties for any personal gain," he said, reading a portion of his letter of resignation to the board. "I have at all times given utmost priority to making myself available over any franchise commitment, and have at times pre-terminated franchise commitments in order to fulfill national obligations. Subject to me being selected for national duty, I would ensure my fullest commitment to the national cricket team. Moreover, I would at all times support and guide our profusely talented young team, as well as my successor, in every way."
Chandimal was always a top contender to take over from Mathews, particularly because he had been groomed as a leader in the past. Though Chandimal's patchy form in ODIs led to his exclusion from the recent squad to play Zimbabwe, he has matured as a Test batsman - most recently making a difficult ton against Bangladesh at the P Sara Oval. He averages 41.17 since the start of 2015, and has scored 2540 runs at an average of 42.33 all told. Chandimal had also been a successful captain at school level, leading Ananda College to record number of outright victories in his senior year.
"I want to take this team and Sri Lanka forward, so I will put my heart and soul into the job," Chandimal said after the announcement. "I'm very thankful to the job that Angie [Mathews] has done for us. Captaincy is not an easy job and he was an excellent leader for us over four-and-a-half years. He's also a terrific batsman and a match-winner for us, and I have huge hopes that he will continue to be one in the coming years as well."
Tharanga's rise to the limited-overs captaincy has been sharper. He had been dropped from Sri Lanka's limited-overs sides as recently as the first half of 2016, but has since led the team in 14 ODIs, as acting captain in Mathews' absence. He has been in excellent form in recent months, however, averaging 49 in ODIs since November. He has been moved around the batting order during that time, sometimes opening the batting, and batting in the middle order at others. Sri Lanka have won four and lost eight of the ODIs Tharanga has captained - six of those losses coming against South Africa.
Tharanga also thanked Mathews for his leadership, and the selectors for giving him the opportunity to lead. He acknowledged that Sri Lanka's recent performances had been modest.
"I don't want to say that as a team we've done poorly in the recent past, but we have had some ups and downs," Tharanga said. "Some matches we do well, and others we don't. In future we have to be more consistent. We all want to take Sri Lanka forward."