England U-19s 208 and 24 for 1 trail Sri Lanka U-19s307 (Vithanage 80, Daniel 52) by 75 runs
While their counties Warwickshire and Yorkshire were squaring up in a Championship match at Headingley, Panayi and Barnes each took three wickets. Gloucestershire's George Hankins provided good support with four slip catches - although the tourists still claimed a first-innings lead of 99 thanks to half-centuries from lower-order batsmen Navindu Vithanage and Jehan Daniel.
England then suffered another blow in a gloomy evening session as captain Max Holden, who had carried his bat for 111 in the first innings, was bowled off an inside edge driving at Lahiru Kumara. They will resume on Friday on 24 for 1, still 75 behind.
England needed early wickets when Sri Lanka resumed on 48 for 1 in reply to a below-par total of 208, and after a frustrating start Panayi and Aaron Beard delivered with three in consecutive overs.
Panayi, who signed a professional contract with Warwickshire earlier this year and is one of two Shrewsbury School products in the team with the Worcestershire opener Olly Westbury, had taken the first wicket on Wednesday, and added the important scalp of Sri Lanka's captain Charith Asalanka with a good return catch.
Then Beard, who made his first-class debut for Essex earlier this season, had Wanidu Hasaranga edging to Surrey's Ollie Pope, who produced a tidy performance in front of the England wicketkeeping coach Bruce French.
When Panayi bowled Shammu Ashan for a duck as he tried to withdraw his bat, Sri Lanka had lost three wickets for six runs and stumbled to 79 for 4.
They recovered with a fifth-wicket stand of 51 before Barnes claimed two wickets in three overs in a fine spell from the Wantage Road end, as first Avishka Fernando, then Ashen Bandara edged into Hankins's safe hands at second slip.
That was 153 for 6, but England were then frustrated by a seventh-wicket stand of 94 between Daniel and Vithanage.
It was finally broken by Amar Virdi, a Surrey offspinner who had a net session with Monty Panesar on Wednesday, as Daniel edged a cut and Hankins claimed his third catch.
Holden confirmed the value of his occasional offspin by taking the eighth wicket in a tidy nine-over spell, and then Beard and Barnes polished off the tail in four overs with the new ball.