Starc then had Jonathan Wells caught in the slips by captain Steve Smith with the first ball of his next over, as NSW secured a dramatic win with almost ten overs to spare.
"The shape he (Starc) gets and the angle he creates from going so wide - it's difficult for batters alone let alone tail enders," Smith said of Starc.
"Most people are pretty lucky to take one hat-trick in their career, but two in a game is a pretty fantastic effort."
It was the first time in Australia that a bowler had taken two hat tricks in a first-class game and over 100 years since an Australian had achieved the feat anywhere.
Australians Albert Trott and Jim Matthews both managed it in England.
Trott did it for Middlesex in a county game and Matthews in a Test against South Africa in Manchester in a triangular Test series.
WA looked poised to mount a serious chase of their testing target after an opening stand of 179 between Marsh and Cameron Bancroft, who followed up his gritty unbeaten first innings 76 with a more fluent 86.
Test hopeful Hilton Cartwright collected a pair and lasted just 11 balls across the two innings.
Josh Hazlewood (3-49), Pat Cummins (2-52) and spinner Nathan Lyon (2-56) worked their way through the top and middle orders, with the quicks reverse swing proving a potent weapon.
"They bowled brilliantly with the reverse swinging ball," WA coach Justin Langer said.
Earlier on Tuesday, Smith posted his 34th first-class century, striking 17 fours and a six to get 127 off 167 balls.
The Blues added 134 in 95 minutes before Smith declared at 6-300.
Smith put on 140 with Kurtis Patterson (66) and 85 with Moises Henriques (45) for the third and fourth wickets respectively.
- AAP