The 24-year-old, selected in the 12-man Test squad to face Pakistan on Thursday, took four for 34 as Yorkshire coasted to a comfortable victory.
Shahzad's efforts together with a fine unbeaten innings of 86 by Jacques Rudolph means Yorkshire top Group B with five wins from as many games.
Middlesex, who won the toss and elected to bat, were never really in the game after losing three wickets in the opening nine overs.
The initial breakthrough came from only the eighth ball of the afternoon when Shahzad enticed Scott Newman to edge an attempted drive and Jonathan Bairstow claimed a simple catch.
Neil Dexter was the next to go when, after hitting five boundaries in a promising 25, he tried to lift Tim Bresnan over the top but only managed the find Steve Patterson at mid-on.
Bresnan, a surprise omission from the England Test squad when it was announced earlier today, then claimed his second wicket after Owais Shah had made an ill-fated attempt at hooking a short delivery for Bairstow to again take the catch behind the stumps.
With Middlesex struggling on 38 for three, Dawid Malan and Gareth Berg stabilised the innings by adding 61 runs in 15.4 overs before Malan was dismissed for 28 when the left-hander flicked a flighted delivery from David Wainwright to Richard Pyrah.
After that, wickets fell on a regular basis with Bairstow collecting his third catch as John Simpson edged an Adil Rashid delivery.
A poorly-executed sweep from Gareth Berg saw the South African top-edge Wainwright to Andrew Gale before Tom Scollay, after hitting a useful 32 from 18 deliveries, was bowled by Shahzad.
The 24-year-old then claimed the wickets of Tom Smith and Shaun Udal in the final over as Middlesex finished on 183 for nine.
Yorkshire enjoyed a fine start with Gale and Rudolph helping the visitors reach 50 in 10.4 overs.
The century stand duly followed 10 overs later before Middlesex finally made a breakthrough when Gale was stumped by Simpson to give Australian Scollay his first wicket in English domestic cricket.
Adam Lyth then offered a return catch to Pedro Collins on 34 but Yorkshire would not be denied as Rudolph pushed on to finish unbeaten on 86 and ensure the visitors won with 18 balls to spare.