Denly and Stokes came together after England lost Rory Burns for 20 and Joe Root (21) in the morning. Burns had driven Peter Siddle sweetly through mid-off to bring up the first half-century opening stand of the series but he departed after a wild slash at a wide ball from spinner Nathan Lyon which he edged to wicketkeeper Tim Paine.
Captain Root, bidding to register his first test century in the series, pushed forward tentatively at Lyon and nicked a simple catch to Steve Smith at slip and the home side took lunch on 88 for two. Stokes, dropped at slip off Lyon on seven, started slowly before unfurling some trademark attacking shots to entertain a packed crowd.
Denly clipped Josh Hazlewood through mid-wicket for his seventh four to reach fifty for the third time in the series and the 33-year-old right-hander struck a few sweetly-timed strokes in his highest test score.
Stokes, who made a brilliant century to lead England to a dramatic victory in the third test at Headingley, moved past fifty with a six off Marnus Labuschagne before he was bowled by Lyon to end a fine third-wicket partnership of 127.
Denly's five-hour vigil was halted when he edged Siddle to Smith at slip and Jonny Bairstow fell for 14, nicking another catch to Smith off the bowling of Mitchell Marsh. Sam Curran was caught down the leg side by Paine off Pat Cummins for a breezy 17, Chris Woakes was brilliantly caught one-handed by Smith off Marsh and Jos Buttler plundered 47 before skying Siddle to a diving Labuschagne at square leg.
Jofra Archer and Jack Leach steered England through to the close without further loss and Australia will face a daunting run chase over the remaining two days of the match.