TNZ skipper Peter Burling later told commentators "We were just turning the boat as hard as we could ... we were lucky not to end up on our side ... in these boats you need more room than that."
Burling had gained an advantage at the start, when he forced counterpart Nathan Outteridge across the line early and then took maximum gain from the two boat-length penalty.
The Kiwis were ahead at the second mark, but made a bad tack and Sweden generated greater boat speed to take a three-second margin at the third mark. At times, the Swedes showed superior pace throughout, hitting speeds of up to 40 knots.
But they jibed badly down the fourth leg to allow Team NZ back on level terms at the next turn, setting up some classic match-racing exchanges.
Burling held his nerve, barely clearing his opponent to snatch and edge at the fifth mark, but Sweden gained an advantage down the right side of the course to lead into the final rounding.
Earlier, Team France continued their renaissance at the regatta, upsetting Ben Ainslie Racing (GBR) for their second win of the week.
Trailling by 15 seconds at the second mark, French skipper Franck Cammas powered past his opponent at the third turn and built a 10-second advantage down the next leg.
When Sir Ben Ainslie tacked badly, Team France had victory in hand and they stretched their margin to 53 seconds by the next mark and held it to the finish. Game over.
Both Oracle Team USA and Emirates Team NZ put more than a minute on the French on opening day, but after toppling Team Sweden yesterday for their first win, Cammas has now claimed another prized scalp.
Although their boat handling was still rough at times, they have been the big improvers over the opening days of sailing.
Meanwhile, BAR, damaged in a collision with Team Japan on day one, have now lost four straight races and need to find a way back into the contest.