Pirri scored on the rebound of a Nate Schmidt shot at 8:48 of the second period to cut the Islanders lead to 2-1.
Alex Tuch appeared to tie it 2-2 at 15:31 of the second period, but Trotz challenged for offside, and the goal was overturned after video review showed Tuch entered the zone ahead of the puck at 15:26.
Midway through the second period, Vegas coach Gerard Gallant moved Tuch up to the top line with Jonathan Marchessault and Karlsson, dropping Reilly Smith down to play with Stastny and Pirri.
Smith had the primary assist on Stastny's go-ahead goal.
"[Smith's] easy to play with," Stastny said. "He holds on to the puck, buys you that extra second when you play the give-and-go game. He was resilient on the puck all night, and that's what gave us our second chances."
Gallant would not confirm if he will use those lines going forward.
"But I liked it," he said.
Schmidt scored an empty-net goal with 15 seconds remaining for the 4-2 final score.