The Ducks lost their third straight despite taking the lead two minutes into the game.
Nashville grabbed a 3-2 advantage in the third period but Ryan Getzlaf tied it with a power-play goal with 10:27 left in regulation.
Hamhuis then came through with a slapshot that got past Jean-Sebastien Giguere.
The Predators won their second straight and moved within two points of Chicago for second place in the Central Division.
Dan Ellis made 32 saves to get the win. Giguere stopped 31 shots.
Millions of Getty images now available for free via embed tool
Boston schools pull out free condoms over wrapping complaints