Jason Dickinson and Jason Robertson scored for the Stars (5-3-4), who have not won in five games (0-2-3). Jake Oettinger made 18 saves.
Joe Pavelski's wrist shot off a pass from Jamie Benn on the power play with 40 seconds left in the third period tied it 3-3.
"Did we play well enough to win that game? Yeah. Are we throwing points away? Yeah, we are," Dallas coach Rick Bowness said. "We're outplaying teams and giving away points, so that has to correct itself here. We're going to need more from everyone to make that balance swing in our favor."
Dickinson gave Dallas a 1-0 lead at 5:49 of the second period. Nedeljkovic saved Andrew Cogliano's shot through traffic, but Dickinson scored with a backhand on the rebound.
Martinook's first goal of the season tied the game 1-1 at 17:29. He scored on a redirection in the slot off a pass from Jake Gardiner.
"We weren't really clicking," Gardiner said. "We were a little off, but good teams find a way to win."
Teravainen made it 2-1 when he took a cross-ice pass from Martin Necas and scored into an open net from the left circle at 19:53.
Andrei Svechnikov passed from behind the net to Jordan Staal in the slot for a power-play goal that pushed Carolina's lead to 3-1 at 2:06 of the third period. John Klingberg was serving a tripping penalty.
"Right after you give up a goal you want to have a strong shift," Klingberg said. "I [took] a penalty. So that's what happened. They scored another goal."
Robertson one-timed a pass from Roope Hintz from the top of the left circle to get Dallas within 3-2 at 8:22.
The tying goal was set up by a remarkable defensive play. With Sebastian Aho leading a 2-on-1 toward the Stars' empty net, Dallas defenseman Miro Heiskanen spun to his backhand and broke up Aho's pass with a no-look sweep of his stick that transitioned the puck to Klingberg.
"He swings his stick in the (passing) lane. That's something that only Miro is doing," Klingberg said. "Then we were able to go the other way, and it was an unreal shot by [Pavelski] as well."
The shootout was Nedeljkovic's first in the NHL.
"It's frustrating to give up two late goals like that," Nedeljkovic said. "Probably both of them, honestly, I would like to have back. But to be able to just get the win, it's just finding ways to get that extra point."
NOTES:Prior to the game, the Hurricanes acquired forwards Cedric Paquette and Alex Galchenyuk in a trade with the Ottawa Senators for forward Ryan Dzingel. … Necas played 17:41 after missing three games with an upper-body injury. … Carolina had a season-low 21 shots. … Brock McGinn had his four-game goal streak end. … Pavelski leads the NHL with seven power-play goals, one more than he scored in 67 games last season.