The Rams appeared to be in command after building up a 30-4 lead after 53 minutes only for Oldham to hit back with four converted tries in the final 22 minutes to almost snatch a dramatic win.
Ayden Faal, Ben Jones, Ed Barber and Dwayne Barker scored first half tries for the Rams, with Scott Spavin landing two goals to put them 20-4 ahead at the break.
Darrel Olpherts and substitute Matt Nicholson extended the lead with second half tries, one of which was improved by Spavin, before Oldham fought back in the final quarter.
John Gillam led the way with a hat-trick of tries, while Neil Roden and John Clough also scored, with Jamie Dallimore adding four goals.
Despite victory, Dewsbury are unable to qualify for the knock-out stages of the competition going into this Sunday’s final group game against Rochdale.
Match report and latest Rams news in Friday’s Dewsbury Reporter.