According to the sporting regulations Lewis should not have been allowed to rejoin the race:
Chapter III paragraph 6.1 of appendix H of Int Sporting code
If a car stops
If a car stops on the course, or leaves the track, the first duty of the course marshals in that sector is to take it to a place of safety.
No driver has the right to refuse to allow his car to be taken off the track, he must do everything he can to help and obey the
marshals’ instructions. Once the car is in a place of safety the
driver may, if the specific regulations of the event permit, workon it in order to re-start. In such cases other means, such as breakdown vehicles, cranes, etc. should not be brought into action until the driver has made it clear that he will not continue. It is desirable that the driver stays near his vehicle until the end of the race or at least informs the post chief how his car may be lifted, or towed back to the pits.
Also:
Chapter IV paragraph 3 appendix L of Int Sporting Code
Stopping of a car during the race
a) the driver of any car leaving the race shall signal this intention in good time and is responsible for ensuring that the manoeuvre is carried out safely and as near as possible to the point of exit.
b) should a driver be compelled to stop his/her car, either involuntarily or for any other reason, the car shall be moved
off the track as soon as possible so that its presence does not
constitute a danger or prevent the normal running of the race.
If the driver is not able to move the car out of the potentially
dangerous position, it is the duty of the marshals or other officials to help.
In that case, if the driver succeeds in re-starting the car without any external help, and rejoins the race without committing any breach of the regulations and without gaining any advantage from the preceding movement of the car to a safer position, he/she will not be excluded from the race.
Guess the marshalls and the race stewards decided it was ok but the FIA turned a blind eye to their own regulations, Lewis technically should have been black flagged. If Lewis had scored points and the FIA allowed him to keep them it would be nuts.