The slow left-armer, in his first season with Surrey, captured five of the last six wickets as the Sri Lankans fell from 170 for 4 to 190 all out in the space of 12 overs.
Bainbridge took full advantage of a turning pitch but was assisted by some risky Sri Lankan batting after the openers, Russel Arnold (63) and Sajith Fernando (32), had given them a good start with a stand of 51 in 13 overs.
England tightened their grip, and increased their chances of breaking the stalemate after two draws, with Essex's Darren Robinson reaching 56 not out in a reply of 103 for 1.
Alan Wells, the Sussex captain, hit his fourth first-class century of the season as his side amassed 331 for 3 against Lancashire, at Old Trafford. Wells, who was dropped in the gully by Mike Watkinson off Peter Martin before reaching double figures, punished Lancashire with an unbeaten 135 in more than five hours.
He shared a third-wicket stand of 263 with Neil Lenham, who added his third hundred of the year and passed 1,000 first-class runs for the summer.
An unbeaten sixth-wicket stand of 79 between Neil Taylor (60) and his vice-captain, Steve Marsh (27), helped Kent recover from losing half their side for 55 on a busy day at Canterbury. Kent, bidding to finish runners-up behind Essex, were 134 for 5 at the close - 24 behind Glamorgan. The Welsh side had been dismissed for 158, Alan Igglesden finishing with 5 for 45 and Matthew Fleming 3 for 31.