The two title contenders started the 42-lapper side-by-side on the front row, Kostecki getting the best of the run to turn 1 from the outside to sweep into the lead ahead of van Gisbergen and David Reynolds.
The leading trio then continued to run in that order across a fairly tame first stint, Kostecki's advantage sitting at around half a second.
That was until the end of lap 17 when van Gisbergen made his move, forcing Kostecki to the inside on the run to turn 7.
The Kiwi was then able to get a better run onto the front straight and ease past Kostecki into turn 1.
Kostecki didn't give up, barging down he inside of van Gisbergen into turn 7 on the very next lap – only to pit immediately after reclaiming the lead.
The squabble proved costly, though, with Reynolds – who had pitted on lap 17 – able to undercut Kostecki.
The pair then battled over what would become the effective lead until Kostecki was able to sneak back through at turn 7.
Van Gisbergen, meanwhile, stayed out until lap 28 before resuming in what was effectively fourth behind Kostecki, Reynolds and James Courtney.
He did have better tyre condition, though, and within a handful of laps was able to clear both Courtney and Reynolds.
He then set about running down Kostecki's two-second lead, the battle coming to a head 13 laps from home.
It was at that point that van Gisbergen got a run down the back straight, forcing Kostecki to defend into turn 7.
Kostecki then continued to defend staunchly, the pair making contact a number of times over the laps that followed.
Kostecki was eventually shown the bad sportsmanship flag for his defence, at which point van Gisbergen was able to squeeze past at turn 6.
That was all he needed to secure victory by 0.5s over Kostecki.
"I hope everyone enjoyed that, that was really cool," said van Gisbergen.
"I got a bad start and then I knew my car was good, but couldn't quite get through.
"We had an awesome battle in the middle but we were losing time to the guys that pitted. The stop was awesome and I drove through to catch those guys. That was really, really cool."
Kostecki added: "That was a lot of fun in the car. To come off second best is not ideal, but we gave it a crack. It was a really good race with Shane. We'll see what we can do tomorrow."
Reynolds finished third, less than a second behind van Gisbergen having been brought back into contention by the battle for the lead.
Todd Hazelwood put in an impressive drive to finish fourth, a late stop helping him run down Courtney.
Matt Payne was a fine sixth in the second Grove Mustang ahead of Tim Slade, Will Davison, Thomas Randle and Broc Feeney.
Chaz Mostert made some ground from his difficult qualifying session, but still had to settle for 11th.
Kostecki continues to lead the series over Mostert, the gap 76 points, while van Gisbergen sits third, 78 points in arrears.
The Perth SuperSprint continues with two qualifying sessions and two races tomorrow.