Ferrari's Sebastian Vettel pulled off a shock to take victory at the Malaysian Grand Prix, with World Champion Lewis Hamilton having to settle for second.