Nolan Allan and Tyler Toffoli scored, and Kiefer Sherwood had two assists for the Sharks (6-4-1), who won their first game in regulation this season. Yaroslav Askarov made 41 saves.
Tim Stutzle and Jordan Spence scored for the Senators (7-4-0), who defeated the Florida Panthers 5-1 in Brady Tkachuk’s return to Ottawa on Wednesday, but have lost two of their past three games. Samuel Ersson made 22 saves.
Stutzle gave the Senators a 1-0 lead on a delayed penalty at 6:16 of the first period. Stutzle came on the ice as the extra attacker, received a cross-ice feed from Drake Batherson in the left face-off circle and buried a wrist shot five-hole on Askarov.
Carter Yakemchuk appeared to make it 2-0 at 11:26, but after video review it was determined that the puck hit the left post and crossbar and never crossed the goal line.
Allan tied it 1-1 at 11:04 of the first, beating Ersson over the glove into the top-right corner.
San Jose scored a power-play, short-handed and even-strength goal in a span in a 4:05 span in the second period to take the lead.
Toffoli put the Sharks up 2-1 at 9:13 of the second period with a power-play goal when his long-distance wrist shot got past Ersson through traffic in front.
Graf scored while short-handed at 12:00 to make it 3-1. He stripped the puck from Stephen Halliday in the defensive zone and began a rush up the ice. After dropping the puck back to Ty Dellandrea, Graf dove in front to tap in the return pass into an open.
Trouba extended the lead to 4-1 at 13:18. Graf drew three Senators into the left corner before finding Trouba alone in front for a quick tap-in.
Askarov made 18 saves in the second, highlighted by a diving glove save on Batherson at 18:04 to preserve the three-goal advantage.
Spence cut the deficit to 4-2 at 6:24 of the third period. Fabian Zetterlund sent a saucer pass to Spence, who buried a wrist shot from between the circles.
Zack Ostapchuk scored a short-handed empty-net goal at 16:31 to make it 5-2, and Ivar Stenberg added another empty-net goal for the 6-2 final at 19:43.
Sharks forward Igor Chernyshov exited the game with 3:49 remaining in the first period after blocking a shot off his left arm from Nikolas Matinpalo.