Williams added two assists, and Rod Brind'Amour set up a goal to extend his point streak to eight games.
Ray Whitney also had a goal for the Hurricanes, who squandered a two-goal lead but scored the winning goal in the final minutes for the second straight home game.
Dallas' Sergei Zubov tracked down a loose puck behind the goal line and tried to send it down the ice, but Williams intercepted the puck in the right circle and beat screened goalie Marty Turco with a high wrist shot.
Staal finished off his third career hat trick with an empty-net goal with 45.6 seconds left. Jaroslav Modry scored with one second remaining for Dallas.
Cam Ward, back in Carolina's net after a rare night off, stopped 21 shots. Turco made 20 saves for the Stars.