Mattis, who began his career with the Terriers, hammered in a low left-foot drive after substitute Sam Parkin headed down a deep cross from Matt Richards three minutes from time.
Theo Robinson put the visitors in front early in the second half, but Darren Byfield levelled from the penalty spot before Mattis gave the Saddlers their first home win of the season.
Huddersfield were in front within two minutes of the restart as leading scorer Robinson burst onto a pass from Jordan Rhodes before rounding goalkeeper Rene Gilmartin and driving the ball into the net.
But Walsall levelled after 65 minutes when a header from Alex Nicholls was handled by Joe Skarz and Byfield drove home the resulting penalty.
Walsall kept up the pressure and Byfield had another goal ruled out for offside before the Saddlers pushed forward again for Mattis to snatch the winner, which extended Huddersfield’s run without a win to four games.