It was the Renault driver's first victory since the Italian Grand Prix last year and capped a remarkable weekend that saw him top two of the free practice sessions but start 15th on the grid after a mechanical problem in qualifying.
He claimed his 20th career triumph by 2.95 seconds over Germany's Nico Rosberg in a Williams and Britain's world championship leader Lewis Hamilton in third.
Toyota driver Timo Glock was fourth with Toro Rosso's Sebastian Vettel following up his win in Italy this month with fifth. BMW Sauber's Nick Heidfeld took sixth.
The race was a new experience for every driver on a street circuit under powerful spotlights and it turned out to be one of the most exciting of the season.
Despite dark clouds lurking, Singapore's notorious tropical downpours stayed away and the whole race was run in dry, but hot and humid conditions.
Ferrari's Massa started from pole but a disastrous mistake cost him the race and valuable points in his push for the world title.
His 13th place finish means he is now seven points behind Hamilton in the championship hunt with just three Grand Prix left at Japan, China and Brazil.
The Brazilian was in the pits on lap 15 when he was given the green light and drove off with the fuel hose still attached to his car, leaving one of the pit crew floored and subsequently carted off in a neck brace.