Gubbins is unbeaten on 96 at tea as the home team reached 168-5 in cloudy conditions in north London.
After Middlesex resumed on 84-3 after lunch, Jack Brooks claimed his third wicket of the innings when he bowled Stevie Eskinazi for 12 off an inside edge.
It left the home side 97-4, and Yorkshire looked to be getting on top on a pitch already showing suggestions of low bounce.
But Gubbins and John Simpson fought hard in an attritional period of play, adding 57 in 24 overs as Yorkshire toiled in vain to break the stand.
They finally did so when Tim Bresnan - hitherto luckless - had Simpson lbw for 15 offering no shot as the hosts slipped to 154-5.
Gubbins, who made his first-class debut for Leeds-Bradford MCCU against Yorkshire at Headingley in April 2013, reached a fine half-century from 94 balls with nine fours.
But he was given a testing working over by Bresnan, who should have had a second wicket with the score on 160 only for Gary Ballance to drop James Franklin on one at third slip.
The ball slipped through Ballance’s grasp and disappeared to the boundary, and at tea Franklin has five to his name.
Jack Brooks gave the visitors the perfect start after Andrew Gale had decided against contesting the toss and struck in the fourth over with the score on 11.
The pace bowler trapped Sam Robson lbw for a duck with a full-length ball that angled in towards leg stump.
Brooks struck again with the total on 33 when Nick Compton shouldered arms and was lbw for eight.
Compton was clearly unhappy with umpire Tim Robinson’s decision and appeared to walk off in a state of wry amusement.
After Brooks’s opening spell of 2-22 from six overs, David Willey relieved the pressure from the Nursery End when he conceded 15 runs off his first over.
Dawid Malan took him for three boundaries in that over - a firm pull, a delicate clip through fine-leg, and a powerful square-drive.
Malan clipped Willey for another boundary in his next over, away through mid-wicket, before the England pace man had him dropped on 19 by Adam Lyth at second slip with the score on 53.
It was a difficult chance, low to Lyth’s right, but one that a slipper of his ability would have expected to take.
Yorkshire dropped a second catch two balls later when Azeem Rafiq put down Nick Gubbins at backward-point off Steve Patterson.
Gubbins, on 22, cut firmly to the fielder, who parried the ball up but was unable to grab the rebound.
Rafiq, who earlier today signed a new one-year contract with Yorkshire, afterwards needed treatment to his right hand but was able to continue.
Malan had added only three to his score after his reprieve by Lyth when Willey finally got him bowled off an inside edge as he attempted to drive through the covers.
Malan’s departure left Middlesex 57-3 in the 18th over and gave Yorkshire their first bonus point of the game.
Gubbins, who has advanced to 42, has played nicely, having started the day with three boundaries off Brooks and one off Ryan Sidebottom, who conceded only eight runs from his opening seven-over spell.
Stevie Eskinazi, who has seven to his name, has kept him solid support, with honours just about even after an eventful session.
To stay updated with all the action - as well as what is going on at Taunton between fellow title hopefuls Somerset who host already-relegated Nottinghamshire – follow our live blog HERE
Yorkshire, who are in second place, nine points behind Middlesex, need to win to preserve their hopes of a hat-trick of titles.
But both teams could be pipped by third-placed Somerset, who have won the toss and elected to bat in their final game against Notts at Taunton.
Yorkshire have left out batsman Jack Leaning and pace bowler Liam Plunkett from their 13-man squad.
Middlesex: Robson, Gubbins, Compton, Eskinazi, Malan, Franklin (captain), Simpson, Rayner, Roland-Jones, Murtagh, Finn.
Yorkshire: Lyth, Lees, Ballance, Gale (captain), Bresnan, Hodd, Willey, Rafiq, Patterson, Brooks, Sidebottom.