Openers Gubbins and Sam Robson, dropped on nine by Kumar Sangakkara, made 126 together before Robson (53) fell after his fourth score over 50 this summer.
Gubbins (91) and Dawid Malan (58) set the visitors up before the latter was caught behind off James Burke [2-56], the first of five wickets for 51 runs.
All-rounder Tom Curran took 3-80 as Middlesex closed on 298-7.
But there is concern for Surrey, as their leading wicket-taker this summer Ravi Rampaul had to go off with an injury midway through an over.
Shortly after Malan's dismissal, Adam Voges fell just short of his half century on 47 before John Simpson, who has made three fifties this summer, went for 12.
Then Paul Stirling and Ollie Rayner both fell to Curran as Surrey will begin day two at The Oval looking to mop up the tail end of their opponents.
Surrey all-rounder James Burke told BBC Radio London:
"It was a difficult surface but the boys pulled together for the last session and for the first time probably this season we worked as a unit.
"Losing Ravi was obviously a big blow, he's been our main strike bowler. So it was up to us to hold our hands up and step up.
"It's a difficult wicket, the ball's quite up and down but I think if you apply yourselves there's definitely runs to be had and we're definitely happy with how we left the day."
Nick Gubbins top-scored for Middlesex before a middle-order collapse pegged them back on day one against Surrey.