Callum Tapping gave the home side the lead after just two minutes when he was on hand at the back post to provide the crucial touch from a cross by Ross Forbes.
Michael Travis almost added a second two minutes later with a header which drifted narrowly wide.
St Johnstone did not produce too much in response in the early stages. Matt Kennedy tested Marc McCallum with a shot from outside the area which the goalkeeper dealt with well.
Worse was to follow for Saints when Forbes drilled home a free-kick eight minutes into the second half to put Forfar in a strong position.
Kennedy pulled a goal back for the Premiership side with a header following a corner midway through the second half but it was not enough.
Hamilton Academical came from two goals down to beat Airdrieonians 3-2 and book their place in the last 16 after clinching runners-up place in Group F. Airdrie drew first blood when Callum Smith thumped the ball into the roof of the net from close range after Sean Crighton had carved out the opening.
Ally Roy doubled Airdrie’s advantage with a stunning strike after a free kick from James Cowan had come back off the defensive wall. But Hamilton were given a lifeline early in the second half when they were awarded a soft penalty and Ross Cunningham sent goalkeeper David Hutton the wrong way with the spot-kick.
Hamilton were awarded a second penalty shortly afterwards from a handball in the area and Cunningham made no mistake to draw level. It was left to a sensational strike from Marios Ogboe to settle it with just a minute remaining.
Arbroath lost 3-2 at home to Alloa Athletic in Group C. Bobby Linn fired Arbroath in front direct from a free-kick after 18 minutes but, within 60 seconds, Liam Buchanan had equalised with a left-foot shot. Alloa moved in front six minutes after the break when Alan Trouten scored with a left-foot shot.
Captain Jason Thomson equalised with a long-range shot with 16 minutes left but Trouten then scored his second.
Dunfermline Athletic crushed East Kilbride 4-0 at East End Park to win Group H after a whirlwind start. A misplaced clearance from goalkeeper Alan Martin was punished immediately as Kevin Nisbet took full advantage to put Dunfermline in front.
East Kilbride contributed to their own downfall and fell two goals behind inside the first ten minutes when Josh Coley took advantage of some slack defending.
Tom Beadling slammed home the third goal with a terrific 20-yard shot after just 16 minutes which left Martin with no chance.
Ryan Dow and Coley both came close towards half time and it was no surprise when Nisbet scored his second shortly after the break with a low shot.
Albion Rovers beat Edinburgh City 2-1 in the other group match.
Euan East gave Albion an early lead after some misguided defending from City and Nicki Paterson headed a second shortly after half-time. Substitute Blair Henderson pulled a goal back from the penalty spot.
Brechin City and Montrose drew 1-1 in Group B. After a goalless first half, Ross Campbell put Montrose in front with a 57th-minute strike but Scott Reekie equalised with 17 minutes to play. Montrose won the penalty shootout 4-2.
Cove Rangers brushed aside Raith Rovers 3-0 in Group D. Cove led at half-time thanks to a Jamie Masson strike in the dying seconds of the half and it did not take long for them to add to their lead after the break. On-loan Chris Antoniazzi found the top corner of the net with a left-foot shot and then Declan Glass made it 3-0.
In Group A, Stenhousemuir beat Cowdenbeath 2-0. Mark McGuigan gave them the lead late in the first half and an own-goal from Jamie Todd completed the scoring.