Glamorgan resumed on 186-5, still 85 runs short of making Middlesex bat again, with the home side in a hurry to wrap the game up given the poor weather forecast for the afternoon.
But Middlesex managed just two wickets in the first session despite Roland-Jones striking early on an overcast morning, as Kiran Carlson looked disappointed to have been given out caught behind.
Timm van der Gugten defied the bowlers for 70 minutes for his 28 before Dane Paterson bowled him with the second delivery of the new ball.
Cooke survived a couple of strong lbw shouts from Roland-Jones but he and Ned Leonard, whose previous best score was 16, nudged Glamorgan precariously ahead the over after lunch.
The eighth-wicket pair settled in with a partnership of 88 and were starting to play their shots, causing Middlesex some frustration.
Brookes got the long-awaited breakthrough when he won an lbw verdict against Cooke after his gritty three and a half hour stay.
Leonard’s valiant effort ended in the next over when he tried to reverse-sweep persevering spinner Zafar Gohar and was bowled, and Brookes had Shoaib Bashir caught as the end came quickly.
Max Holden was promoted to finish the game off quickly, hitting Leonard’s first ball for six and his fourth to mid-off, before bad light and rain interrupted at 16-1 off 3.3 overs.
Middlesex deserved the chance to seal their victory but had to endure a protracted delay after tea with the hover-cover on, and the umpires and ground staff waiting in the middle until the resumption at 17:25 BST.
Stevie Eskinazi and Leus Du Plooy wasted no time in getting the required 43 off a further 4.2 overs, Du Plooy finishing the match with two leg-side sixes off Leonard into the Mound Stand in the space of three balls.
Middlesex travel to Derby on Friday, 25 April, while Glamorgan sit out the next round before hosting Derbyshire a week later.