Robert Earnshaw fired the Welsh into a first half lead but James Morrison marked his 25th birthday with the equaliser soon after the break, before Kenny Miller and Christophe Berra grabbed a goal apiece.
The result means it will be a straight fight between Scotland and the Republic of Ireland to claim the Carling Nations Cup when they meet in the tournament’s final game on Sunday.
Scotland squandered a great chance when Steven Whittaker burst down the right flank before squaring for Miller who failed to connect properly and stab home from just a few yards out.
Charlie Adam then saw his shot deflected past the post and Levein’s men were left rueing those missed opportunities when Wales surged into the lead after 36 minutes.
Neal Eardley punted a long ball up the park which was missed by Stephen Crainey, allowing Earnshaw to race into the box and loft over McGregor and into the back of the net.
Scotland were back on level terms 10 minutes after the restart when Adam flighted a lovely ball from the halfway line into the path of Morrison and he did well to hold off Christopher Gunter before rifling home.
Miller was on target with 64 minutes gone when Morrison turned provider with a simple pass and all that was required from the Bursaspor striker was to slot past Myhill from 10 yards.
Scotland increased their lead with 20 minutes to go when Whittaker’s cross picked out Berra at the back post to nod into the back of the net from close range.
WALES: Myhill, Eardley (Matthews 61), Morgan, Blake, Taylor (Gunter 46), Tudur Jones (Vaughan 72), Dorman (Cotterill 60), King (Ramsey 61), Vokes (Morison 72), Earnshaw, Easter.
SCOTLAND: McGregor, Whittaker (Bardsley 81), Caldwell (Hanley 84), Berra, Crainey (Martin 81), Naismith, Brown, Adam (McArthur 88), Morrison (Robson 74), McCormack (Bannan 73), Miller.
Ref: Craig Thomson (Scotland).