In reply to Australia's first innings total of 316, hosts Sri Lanka, trailing the three-test series 1-0, ended day three on 428 for six wickets for a lead of 112 runs.
At stumps, Mathews remained unbeaten on 85 off 207 balls with debutant Saminda Eranga (5 not out) keeping him company.
Mathews, who has twice been dismissed in the nineties in his 16-test career, was involved in two useful partnerships that enabled Sri Lanka to move ahead of Australia's total.
He stitched together a record fifth-wicket stand of 121 with captain Tillakaratne Dilshan and followed it up with another partnership of 81 with Prasanna Jayawardene.
Dilshan returned to form with a well-paced knock of 83 off 121 balls, which included 14 fours, before he edged Trent Copeland to wicket-keeper Brad Haddin standing up to the stumps.
The ball hit Haddin on his right thigh before he held on to it, bringing an end to a partnership that was Sri Lanka's highest for the fifth wicket against Australia.
Australia had to wait 28 overs for their next wicket when wicketkeeper Prasanna Jayawardene (47) was caught at short mid wicket to give Copeland his second wicket.
The hosts had resumed their innings on 166-2 but were forced to consolidate after Australia picked up the prized wickets of Kumar Sangakkara and Mahela Jayawardene before lunch.
Shane Watson made the first breakthrough when he lured Mahela Jayawardene into an expansive drive outside the off stump that caught an edge and went straight through to Haddin.
Jayawardene (51) completed his half century with nine fours and shared a third-wicket stand of 101 with Sangakkara (79).
Sangakkara, playing in his 100th test match, hit 10 fours and faced 176 balls before Peter Siddle dismissed him with the second new ball.
The ball bounced more than the left-hander expected and took the shoulder of his bat on its way to Haddin.