Narrative:

Enroute IFR over ZZZ when engine stopped. Turned back to ZZZ1 and declared emergency. After establishing best glide; ran emergency checklist. Found fuel selector on right tank. The right fuel gage showed 1/8 to 1/4 tank. Placed fuel selector on both and engine restarted. Advised ATC that engine restarted. They asked if I wanted to continue the flight or land at ZZZ1. I elected to land at ZZZ1.

Google
 

Original NASA ASRS Text

Title: When the engine of his C172 failed enroute on a ferry flight the pilot initially declared an emergency and configured the aircraft for an emergency landing. He then noted that the fuel selector was on an empty or near empty tank. When he selected both the engine restarted.

Narrative: Enroute IFR over ZZZ when engine stopped. Turned back to ZZZ1 and declared emergency. After establishing best glide; ran emergency checklist. Found fuel selector on right tank. The right fuel gage showed 1/8 to 1/4 tank. Placed fuel selector on both and engine restarted. Advised ATC that engine restarted. They asked if I wanted to continue the flight or land at ZZZ1. I elected to land at ZZZ1.

Data retrieved from NASA's ASRS site and automatically converted to unabbreviated mixed upper/lowercase text. This report is for informational purposes with no guarantee of accuracy. See NASA's ASRS site for official report.