Michael Smith produced a superb late rally winning the final two legs in a thriller against Raymond van Barneveld.