From an imposing position of 173 for one shortly before tea the hosts lost nine wickets for 67, bundled aside by Rashid's career-best haul of five for 49 and a lung-busting three-wicket burst from the indefatigable Stokes.
That guaranteed England an improbable first-innings lead of 96, extended by three as Rory Burns and Keaton Jennings fended off four overs before stumps.
Sri Lanka were left dizzy by the speed of developments at Sinhalese Sports Club, one moment basking in the biggest stand of the series - 142 between Dimuth Karunaratne and Dhananjaya De Silva - and the next fighting for a foothold in a game that had been ruthlessly ripped away from them.
England captain Joe Root had been curiously reluctant to use Rashid and Stokes, who bowled just one of the innings' first 41 overs between them. Once unleashed, they threw themselves into the spotlight, Rashid's leg-spin accounting for both of Sri Lanka's set batsmen before he added three more scalps and a direct hit run-out for good measure.
For his part, Stokes defied the oppressive heat and humidity to turn in an exhausting 10-over stint either side of tea, hammering Sri Lanka with fiery, short-pitched bowling and bringing an element of menace no other seamer has been able to muster throughout the trip.
The day began with England frittering away their final three wickets for 24 runs in well under half-an-hour. Moeen Ali and Jack Leach both picked out the safe hands of Angelo Mathews off the bowling of Dilruwan Perera, with Broad completing Lakshan Sandakan's five-wicket haul with a clumsy duck.
A total of 336 looked a little underpowered on a decent surface but an early slice of Jennings' brilliance at short-leg got England up and running in the field. He showed bravery and instinct to follow Danushka Gunathilaka as he advanced down the track at Leach, mirroring the batsman's steps to leave himself perfectly placed to gather a thick edge.
After two remarkable interventions in Kandy, this was another one for the scrapbook but the trail soon went cold for England, Karunaratne (83) and De Silva (73) chipping away at the arrears over the course of 36 energy-sapping overs.
That the pair were allowed to linger so long and so profitably lay at Root's door. He dropped Karunaratne on two, Broad finding the edge in a lively new-ball spell only for Root misread the trajectory at first slip and parry a catchable chance for four off his wrist. He later spilled De Silva on 42, losing control despite wrapping both hands around the ball, with Broad again unfortunate.
They were costly misses, particularly with Moeen and Leach struggling to summon their muse, and both men seemed set to hammer home the point until the belated introduction of Rashid struck gold.
De Silva fell late in the afternoon, turning Rashid to the waiting Jennings. At 183 for two at tea, Sri Lanka still held the balance of power, a position they soon surrendered under a stern examination of wrist spin and pace.
Karunaratne followed a similar route to De Silva, giving away his hard-fought knock just after the restart as Rashid and Jennings combined for a regulation bat-pad dismissal.
The batting side never looked settled again. Stokes, tearing into the crease and hammering the old ball into the middle of the pitch, had already slammed Karunaratne's ribcage when he got his first tangible rewards. A mis-timed pull canonned off the toe of the bat and was well held by Ben Foakes.
The 27-year-old kept pounding away, defying clear signs of weariness to see off Niroshan Dickwella with a strangle down leg and Perera with a ball simply that rapped the gloves as it hurried through.
Rashid's wiles were more cerebral. A googly deceived Roshen Silva, allowing Jennings to take a stunning one-handed catch and move his tally to four in the innings, and a big leg-break to Kusal Mendis offered Stokes catching practice at slip.
Rashid also effected the run out that caught Sandakan short - off the bowling of Stokes, predictably - and pinned Malinda Pushpakumara lbw to wrap things up.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies