The hosts made a terrible start to the match as they fell behind after just two minutes when Jorge Pulido turned the ball into his own net.
They were only behind for 10 minutes, however, as Jose Willian restored parity with the equalising goal in the 12th minute.
Castilla's turnaround was completed shortly before the half-hour mark, with Jose Rodriguez finding the back of the net to put his side in the lead.
Things got even better for the home side before half time as they doubled their advantage through Lucas Vazquez, who beat the keeper to make it 3-1 with just six minutes until the interval.
Las Palmas looked to respond in the second half in order to boost their own automatic promotion aspirations, and they pulled one goal back with 20 minutes left through Benja.
However, Castilla held out for their first win in nine matches to edge ever closer to safety in the Segunda Division.