Glamorgan 112 for 3 (Labuschagne 51) trail Middlesex 410 (Stirling 138, Robson 107) by 298 runs
Stirling hit a Championship career-best 138, his first four-day century in almost two years, while Robson's 107 was his first ton of the campaign.
In a quirk of fate, Ireland international Stirling's previous career-best, 111 against Yorkshire in June, 2017 also came on a day when Robson hit three figures. The duo's efforts carried the hosts to 410 before the bowlers took over to reduce Glamorgan to 112 for 3 in an elongated final session.
Middlesex resumed at 151 for 3 with Robson 15 short of his century and while the former England man accumulated quietly, Stirling was typically aggressive.
An on-drive to midwicket took Robson to three figures, but soon afterwards Marnus Labuschagne spun a delivery just enough to take the edge of the right-hander's bat and give Tom Cullen his second catch of the innings.
Stirling pressed on and with George Scott providing good support, the pair added 76 either side of lunch before the latter was bowled offering no shot to a delivery which came in a touch from outside off-stump.
This was Stirling first first-class knock since Ireland's Test against Afghanistan in March. However, he played with authority, reaching his own century with a sumptuous drive down the ground, his 12th boundary.
To their credit, Glamorgan kept plugging away on a pitch offering less bounce than day one and a little bit of spin and eventually wickets began to fall with regularity.
John Simpson nicked Timm van der Gugten into the gloves of Cullen and then it was the turn of Labuschagne to take centre stage, pinning Tom Helm leg before wicket with a delivery which kept low before castling centurion Stirling nine runs short of what would have been his highest first-class score.
Nathan Sowter struck three boundaries in a breezy 28 but the end came swiftly after tea, when Marchant de Lange had the legspinner caught behind, before sending Tim Murtagh's middle stump cartwheeling.
That left the visitors 35 overs to face and they made the worst possible start. Charlie Hemphrey pushed the second ball of the innings into the covers and called for a run, but non-striker Nick Selman hesitated before setting off and was not in the frame when Nick Gubbins' direct hit sent him packing.
Labuschagne counter-attacked, producing a succession of boundaries, although he was given a life when edging a delivery from Helm to Robson at first slip on 32, only for the umpire to call no-ball.
The Australian Test allrounder made the most of the reprieve, moving to 50 from 57 balls, passing 700 runs for the season in the process, before the second-wicket stand of 80 ended when Murtagh trapped Hemphrey lbw.
New batsman Lloyd could have gone cheaply when flashing at a delivery from Steven Finn, Stevie Eskinazi just failing to cling on to what would been a blinder above his head. However, the former England paceman gained ample compensation from the next delivery when Labuschagne skied another ball which climbed on him, giving Stirling a simple catch at point.
There was still time for in-form Billy Root to be dropped at slip by Robson in the final over of the day, denying Sowter deserved reward for an excellent spell. Nevertheless, Middlesex still have hopes of enforcing the follow-on on day three.