Carson Soucy tied it 1-1 at 5:21 when he got to a loose puck at the bottom of the right face-off circle.
Tavares gave the Maple Leafs a 2-1 lead at 9:55 on a breakaway.
Nylander made it 3-1 at 5:14 of the second period on the power play.
The Kraken scored twice in 2:29 to tie it. Alexander Wennberg cut it to 3-2 at 9:20 on a 2-on-1 with Marcus Johansson, and Colin Blackwell tied it 3-3 at 11:49 on a shorthanded 2-on-1 with Yanni Gourde, after he intercepted a pass from Nylander.
"We don't want to give up that lead, we've been doing it too much lately, but from that 10-minute point on from the third to the end, I thought we did a great job of just making it hard to get through us, breaking it out cleanly and getting the puck up the ice," Marner said.
"We're never down and out of a game; I think that's the belief in our team, in our locker room and on the bench. When stuff like that happens in games for us, we just get over it, make sure we are ready for the next shift and next opportunity to get on the ice and counter back."
Toronto was 3-for-6 on the power play.
"Penalties hurt going against a power play like that," Soucy said. "It was just a couple mistakes that cost us, we kind of got rolling there in the third, got the lead, and then with these guys, just a couple of mistakes and it's in the back of the net. They've got people who can score, one of the best scorers in the league. Too much time in the box, my (cross-checking) penalty late killed us. It hurts."
NOTES: Soucy's goal was his seventh, matching his NHL career high (2019-20). ... Maple Leafs forward Jason Spezza was a healthy scratch. ... Matthews scored his third hat trick of the season and sixth in the NHL. Four Maple Leafs have scored more hat tricks in a season: Darryl Sittler (five in 1980-81), Babe Dye (five in 1924-25; four in 1922-23), Reg Noble (five in 1917-18) and Rick Vaive (four in 1983-84). ... It was Matthews' 11th multigoal game of the season and his 50th in the NHL. Pat LaFontaine (51) is the only United States-born player with more before turning 25.