Flight Crew Instrument; Flight Crew Multiengine; Flight Crew Flight Instructor
Flight Crew Last 90 Days 30; Flight Crew Total 3093; Flight Crew Type 2000
Human-Machine Interface; Situational Awareness
Aircraft Equipment Problem Critical; Inflight Event / Encounter Fuel Issue
Flight Crew Overcame Equipment Problem; Flight Crew Diverted; General Declared Emergency
Aircraft; Human Factors
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.
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.