Anderson picks six as Sri Lanka 381 all out in Galle
Dilruwan Perera was the last man out on 67 as the hosts, who trail the two-Test series 1-0 and resumed the day on 229-4, were bowled out in an extended second session and tea was taken in Galle.
Anderson, 38, denied wicketkeeper-batsman Niroshan Dickwella a century after sending him back on 92 to claim his 30th five-wicket haul and second in Sri Lanka -- his previous best was 5-75 in Galle in 2012.
Anderson, who replaced Stuart Broad in the team for this Test, struck in his first over of the day to send Mathews caught behind for 110 after the former captain added just three runs in the morning.
But the dismissal was skipper Joe Root's mastermind after he reviewed the umpire's call, which was not out, and replays suggested the ball had grazed Mathews' bat.
Fast bowler Mark Wood sent debutant Ramesh Mendis trudging back to the pavilion for nought with wicketkeeper Jos Buttler taking a one-handed diving catch towards his left.
Dickwella made the team fight back with his 16th Test fifty as he put together a 89-run seventh-wicket stand with Perera.
All the 10 wickets went to the pacemen with Wood taking three scalps.