Magnussen and da Costa had led the way from the beginning, when they both capitalised on poleman and championship leader Robin Frijns bogging down as the lights went out.
Red Bull junior da Costa could do nothing about the Carlin car in the lead though, and Magnussen had the gap up to almost seven seconds by the time both had completed their mandatory stops on lap 13.
But from there da Costa was able to chip away at the leader, and with a handful of laps to go smoke started appearing from the right-rear of Magnussen's car.
The Dane appeared to be doing enough to hold onto the lead, going into the final lap still 3.5 seconds clear. That was down to three seconds by the first split, and then Magnussen's car ground to a halt at turn five with a gearbox issue.
That gave da Costa, who joined the series as an in-season replacement for Lewis Williamson, the lead with just over half a lap remaining.
Behind the winner, Marco Sorensen took advantage of making a late pitstop to jump from fifth to third, which became second when Magnussen retired.
One Carlin driver's pain was another's gain though, as Will Stevens inherited third to take his first podium in the series.
Stevens had run third in the opening stint after working his way from sixth on the grid at the start, but he had been no match for Sorensen when the Dane had clear track.
Sam Bird was another to make up places at the start, and after a race spent defending his position from Arthur Pic and title rival Frijns, he came home fourth.
Frijns took fifth, capitalising on an error from Pic on the exit of turn two to pull off a spectacular pass around the outside of turn four. He had already passed the Frenchman earlier in the race, but lost the position during the pitstops.
The Dutchman's recovery was eventful all the way through, particularly when he locked wheels with Kevin Korjus after the Estonian exited the pits between him and Pic.
Frijns went down the inside at turn two, but as the cars became stuck together they ran wide. Alexander Rossi tried to capitalise, but in the madness ended up on the grass approaching turn three.