WATCH: Pietersen, Lambie star in Top 14 clash
South African JP Pietersen touched down twice for Toulon as the hosts led by 10 points with 25 minutes to play at Stade Majol, but Racing roared back with tries from Marc Andreu, Yannick Nyanga and Louis Dupichot.
Toulon, without a host of players on international duty, suffered a first home defeat of the season and were denied the consolation of a losing bonus point by Dupichot's last-minute try.
"It's always a huge challenge to come play at Mayol. These are always special matches. Therefore to come and win here, and do it with 40 points, that will stay with me," said Racing coach Laurent Labit.
"We had to show our true colours, play and enjoy it and that's what happened. Psychologically, I think this win is going to be important for the rest of our season."
A converted Brice Dulin score and Pat Lambie penalty gave Racing the first 10 points of the match, but Toulon responded as All Black Malakai Fekitoa crossed the whitewash before Pietersen followed him minutes later.
But Racing flyhalf Lambie, who kicked four penalties and four conversions, kept the visitors within touch despite further Toulon tries from former England wing Chris Ashton and Pietersen.
Racing trailed 16-26 before launching a furious recovery by outscoring their opponents 24-3 in the final quarter to climb two spots to fourth, with Toulon sliding down three places to eighth.
"To give up 40 points at home is not a pleasant feeling. We work hard all week but at the moment it's not paying off," said Toulon coach Fabien Galthie.
Earlier, New Zealander Tony Ensor scored two tries and created two more as Stade Francais edged Oyonnax 39-35.
Former Highlanders fullback Ensor produced a stunning performance in a thrilling encounter that featured 10 tries.
Having looked set at one point to claim an attacking bonus point, Stade were left clinging on desperately at the end as Patrick Sobela's late try earned Oyonnax a losing bonus.
"We needed the four points. Our counter-attacking was very good, we're satisfied with the way we used the ball," said Stade's New Zealander manager Greg Cooper.
"But unfortunately both teams can be very disappointed with their defence."
The match was off to a flyer when Dug Codjo touched down in the corner with less than two minutes on the clock.
But within a couple of minutes, Ensor went over after Stade wing Djibril Camara played a stunning pass out of the back of his hand to launch a counter attack.
And before 10 minutes were on the clock, Ensor had scored his second, toe-poking on and then scooping up a grubber from flyhalf Jules Plisson before rolling over a tackle to touch down.
But more power from the Oyonnax pack allowed scrumhalf Jeremy Gondrond to dart between lumbering forwards to score.
Ben Botica knocked over a penalty to give Oyonnax the lead, briefly, but Stade struck again on 28 minutes.
Codjo lost the ball in the tackle two metres from the home line and scrum-half Arthur Coville punted forward to launch a long-range counter that ended with Australian lock Hugh Pyle galloping over, with Plisson converting.
Plisson added a penalty to give Stade a 22-13 lead at the break while Oyonnax lost wing Daniel Ikpefan to a sin-binning.
Ensor then teed up replacement Georgian prop Zurabi Zhvania for Stade's fourth score, before setting up O'Connor for a try with a grubber down the left flank.
Ensor didn't distinguish himself as much in defence, though, as Tongan back rower Viliami Ma'afu denied Stade the attacking bonus point with an individual try on 63 minutes.
Minutes later Botica got his name on the try-scoring board, before Sobela scored a minute from time as Oyonnax had one last possession to try and win it but ran out of time.
Stade Francais 39 Oyonnax 35
Toulon 29 Racing92 40
Clermont 39 Lyon 18
Bordeaux-Begles 33 Agen 23
Pau 34 Brive 15
Castres 31 La Rochelle 15
Montpellier 32 Toulouse 22