Gaustad broke a scoreless tie nine minutes into the third, converting Daniel Paille's pass from behind the net. Miller registered his third shutout of the season, helping Buffalo improve to 8-0-2 in its past 10 games and move into seventh place in the Eastern Conference standings, a point ahead of the idle New York Rangers.
Vesa Toskala was sharp in stopping 19 shots for the Maple Leafs, but was caught leaning the wrong way when Gaustad beat him on the short side while parked at the right post. Toskala didn't get much help either on the goal, as Paille eluded forward Nikolai Antropov with a nifty move behind the net.
Toronto had a two-game win streak snapped.
Miller stopped 12 shots in the second period, including seven during a 2 1/2-minute stretch, part of which came during a Maple Leafs' power play. His best series of stops came when he foiled Pavel Kubina's blast from inside the blue line, and then recovered in time to foil Matt Stajan's chance from the slot.
Miller also got a big assist from defenseman Henrik Tallinder with 1:47 left. That's when Darcy Tucker's shot from the right circle got behind Miller, but Tallinder swept it from danger.
The Sabres won despite being the more tired team, playing their sixth game in nine days, including a 5-1 win at Ottawa on Tuesday.