The victory was the first for Wilson in 15 IndyCar Series races.
Castroneves had led for 53 laps but relinquished the lead when he was penalized for blocking with 20 laps to go.
"It's been a difficult year, but it's great to finally get a win," Wilson said.
"I do not have anything smart to say right now," Castroneves said after the race.
Senate Democrats to pull all-nighter on climate change
Teacher apologizes for showing sexual image of herself in class