Jake Ball took 5-66 as the visitors were bowled out for 247, before Notts reached 24-0 at the close on day two.
Ball's hat-trick late on day one had left Middlesex 0-3 in the first over of their reply to Notts' 241 all out.
Nick Gubbins made a patient 75 from 226 balls as Middlesex scored just 149 runs in the first two sessions.
Captain James Franklin (40) and the rest of the batting line-up were similarly watchful following the carnage at the start of their innings, but it was down to last-wicket pair of Tim Murtagh and Steven Finn to guide them to a slender advantage.
Ball had to wait until after tea for his first wicket of day two, having Franklin caught at third man, before he caught and bowled Toby Roland-Jones to complete his second five-wicket haul in the Championship this season.
Notts openers Steven Mullaney and Jake Libby added some handy runs at a quick rate in the final five overs of the day and, crucially, negotiated them without loss.
Division One leaders Middlesex gained a narrow first-innings lead of six runs over bottom side Nottinghamshire in an intriguing contest at Trent Bridge.