White plays to get his King in front of the Pawn. The position is then a win, no matter whose move it is.

  1. Kf7!

Thee is no win after 1. g6+ Kh8, 2. g7+ (2. Kf7 stalemates Black) Kg8, 3. Kg6, and Black is stalemated. Notice that the Pawn check at the seventh rank does not win unless White controls the queening square.

  1. ...      Kh8
  2. Kg6   Kg8
  3. Kh6   Kh8
  4. g6     Kg8
  5. g7

The winning idea. The Pawn reaches the seventh rank without checking.

  1. ...       Kf7
  2. Kh7

 Seizes control of g8, the Pawn's queening square.

  1. ...       Ke7
  2. g8=Q

White wins.