Left-arm spinner Rangana Herath was almost unplayable on a deceptively turning track at the SSC ground, conceding just 40 runs off 45 overs for five wickets.
Off-spinner Dilruwan Perera was also effective, picking 3-60 off 44 overs.
The duo bowled relentlessly, helping Sri Lanka complete 94 overs on the fifth and final day despite several rain interruptions.
"I'd like to make a special mention about Herath and Perera for the effort that they put in," Mathews told reporters after the game ended.
"They were unbelievable. It was always going to be hard to dismiss (the South Africans) but they put their hearts out to help us win the game. Unfortunately we could not pull it off."
Mathews said the team was gutted because the draw handed South Africa their first Test series win on the island in 21 years.
South Africa had won the opening Test in Galle by 153 runs to go 1-0 up in the two-Test series.
- Tense finish -
"We all wanted to win this game because we knew we didn't play well in Galle. All of us were hungry to win this game. I saw that hunger in all the eleven of us but unfortunately the South Africans held on," Mathews said.
The Sri Lankan skipper defended the ploy to play three specialist spinners in the match although Ajantha Mendis came a cropper with the ball, going wicketless in the two innings.
"We had to take that chance. We knew our seamers won't trouble them as much our spinners.
"We thought Mendis could make a difference but he had quite a bad game," he said.
Rival captain Hashim Amla also gave credit to Herath and Perera for making it a tight finish for them in the end.
"It was a slow scoring Test match for us but I think the credit goes to the spinners and the Sri Lankan team who really made it difficult for us out there," said Amla, 31."There were nerves, tension, fingernails got bitten in the dressing room. It was emotionally draining to watch the guys try and save the game for us. We almost reached our breaking points."
Amla said it was a "pleasing feeling" to win his first series as captain and see the team jump on top of world Test rankings.
"But to be honest, our primary aim was not to get to number one. (Our aim) was to find a winning formula for a newish team.
"Not many foreign teams come to Sri Lanka and win series. So I am thankful to the team for showing so much commitment."
South Africa are in a rebuilding phase after the retirement of their long-standing skipper Graeme Smith and legendary all-rounder Jacques Kallis.
Amla was named the captain last month, becoming the first non-white player to lead the Test team in a full-time capacity.