Two goals in five first-half minutes from Kike Sola and Javad Nekounam set Osasuna on their way and Fernando Soriano made it 3-0 in the 49th minute.
Racing pulled a goal back almost immediately through Markus Rosenberg and the Cantabrian side received a further boost 15 minutes from time when Osasuna midfielder Soriano was sent off after picking a second caution.
Osasuna were not to be denied though and they held on to record back-to-back victories for the first time in over a year, having last week claimed a first away victory since January 2010.
The victory lifts Osasuna six points above the relegation zone and they are also now two points clear of Racing, who, having picked up seven points in their first three games under new coach Marcelino Garcia Toral, have now suffered successive defeats.
Osasuna, who have now won three times in five matches under their new manager Jose Luis Mendilibar, had lost 10 of their previous 13 league and cup matches with Racing, drawing the other three, but they looked well on the way to breaking that dismal record after taking a 2-0 lead inside 25 minutes.
The opening goal came after a deep cross from Javier Camunas beyond the far post was volleyed back into the danger zone by Alvaro Cejudo to Sola, who bundled the ball in from six yards out.
Sola was involved again soon after as Osasuna made it 2-0 from the penalty spot.
Sola was bundled over from behind by Christian Fernandez as he shaped to shoot inside the area, and from the resulting spot-kick Nekounam easily beat Racing goalkeeper Antonio Tono.
Osasuna all but ensured the points would be staying in Pamplona when they added a third soon after half-time when Soriano tapped into an empty net after Camunas tackled a Racing defender before he could clear in front of goal.
Racing gave themselves a glimmer of hope three minutes later when Rosenberg created space for himself on the edge of the box before drilling a low shot past Ricardo Lopez, and they looked right back in the game when Soriano was shown a second yellow card for handball in the centre of the pitch.
That could have set up a grandstand finale, but Racing could not make the most of their numerical advantage and in the end Osasuna held on relatively comfortably for a vital victory.