The tourists batted at the start and the end of the day - all out for 342 then 38-0 at stumps - and in between rolled Sri Lanka over for 203 in just 68 overs.
With a lead of 177 and three days to go, a first English victory at this famed Sri Lankan stronghold is well within sight.
Foakes started the day by putting the finishing touches to a classy maiden century and was last man out for 107 after adding 20 his overnight score.
He then gave a taste of the wicketkeeping skills which earned him his call-up in the first-place. Dimuth Karunaratne allowed the Surrey man to open his international account after just two balls in the field, feeling for James Anderson’s outswinger, and later he produced a highly accomplished stumping to break Sri Lanka’s best partnership of the day.
There was one more chance to impress and he duly took it, pouching a thick edge safely standing up to the stumps in the midst of a Sri Lankan collapse which saw them cough up a potentially match-defining first-innings deficit.
There is a potentially ticklish dilemma coming for the selectors, with Foakes giving every impression of being undroppable and previous incumbent Jonny Bairstow recovering fast from his ankle injury.
To focus solely on Foakes’ contributions would be to do a major disservice to the England attack, though, and particularly their trio of tweakers.
Sri Lanka are used to bundling visiting teams out with spin in Galle but here they were the prey, losing eight wickets to the turning ball. Moeen Ali led the way with 4-66 while Adil Rashid and Jack Leach took two apiece.
With Anderson and Sam Curran removing one opener each with the fleeting swing offered by the new ball, things were going close to plan in the field.
All that was needed to put a ribbon on the day was for Keaton Jennings and Rory Burns, fit after a blow to the back of the neck fielding at short leg, to negotiate 12 overs before stumps and they did so with minimal fuss.
Play began with England 321-8 and several thousand sets of fingers crossed that Leach and Anderson could linger long enough to see Foakes from 87 to 100.
He promptly stroked the first ball of the day for four and was five short of his landmark when Leach nicked Dilruwan Perera to slip. A nervy moment, perhaps, but one Foakes banished with two more boundaries, pulling Suranga Lakmal to fine leg then punching back down the ground to celebrate in style.
He was gone moments later but had already inked his name into the record books as England’s 20th debut centurion and just the second wicketkeeper, following Matt Prior in 2007.
The Sri Lanka innings was topped and tailed with a cluster of wickets, 42-4 in 19 overs before lunch and 67-5 in the 19 overs after tea.
What happened in the afternoon session was a cool-headed aberration as both Dinesh Chandimal (33) and Angelo Mathews (52) knuckled down. Only Foakes’ stumping of the former prevented England going wicketless for two hours.
Either side they batted raggedly. Karunaratne and Kaushal Silva both failed to see the shine off the ball, after which it was spin all the way.
Leach’s nagging discipline earned him the scalps of Kusal Mendis and Perera, while Rashid was used more sparingly on his way to 2-30.
Moeen reaped the biggest rewards, though, bowling Dhananjaya de Silva on the sweep and getting the key scalp of Mathews with the first ball after tea.
By now in a groove, he tempted Niroshan Dickwella and Akila Dananjaya to give up catches in successive overs.