But his victory was tinged by controversy when he collided with Andretti Autosport team-mate Louis Foster as they duelled for the lead with eight laps to go, which forced the British driver out.
McElrea had “burned up” his rear tires and only just held off his other team-mate, James Roe, for the win.
LA-born Kiwi McElrea led the 19-car field to green, heading Roe and Foster on the opening lap, the latter having swept around the outside of Kyffin Simpson at Turn 1.
Behind them, Josh Pierson picked up fifth from Reece Gold before falling back to eighth. Simpson also tumbled to sixth, as Gold and Jacob Abel moved ahead.
Foster passed Roe at Turn 1 on lap two to grab second, allowing McElrea to pull a second clear out front.
Championship leader Rasmussen qualified down in ninth but picked up a spot from Pierson. That put him in sight of his main title rival, Nolan Siegel, who ran seventh.
Siegel grabbed sixth when Simpson locked up and ran wide at Turn 1 just before half distance.
Foster chased down McElrea, causing him to defend for the first time at Turn 1 with 13 laps remaining. Foster then got a run on the back stretch but couldn’t find a way past there either.
With 10 laps to go, Siegel gave up sixth to Simpson.
McElrea then ran wide at Turn 7, so Foster attacked at the next opportunity but McElrea turned in and they collided. Although the contact was light, it damaged Foster’s left-front suspension and he was forced to retire.
“I went for a move and he turned in on me and I got damage,” said Foster. “It’s the second time it’s happened with that driver, and I expected more space from a team-mate.”
McElrea said: “I was surprised by the contact.”
That promoted Roe to second from Gold, Abel and Simpson. Rasmussen worked his way up to sixth, ahead of a charging Danial Frost, Pierson, Kiki Porto and Jamie Chadwick, as Siegel tumbled to 12th.
The drama wasn’t over at the front, however, as McElrea hemorrhaged time to Roe in the closing laps. They started the last lap less than 0.5s apart, but McElrea hung on by 0.437s at the checkered flag.
In other incidents, Victor Franzoni exited with a broken left-front corner at Turn 1 but managed to coast all the way through the run-off to oval Turn 4 so it didn’t cause a caution.
Rasmus Lindh punted Francesco Pizzi into a spin with five laps to go.