How do I promote my pawn when the king blocks it? I was playing ChessEndGames and ran into this position (white to move):

[fen "5k2/8/4PK2/8/8/8/8/8 w - - 0 1"]


I can't get my pawn to promote. As soon as I do e7, black follows with Ke8. If I do Ke5, black does Ke7. If I do Kf5, black does Ke8, and if I follow it with Ke5, black does Ke7.

I am in deep trouble. I don't get it how to promote my pawn.
This position is a draw with White to move. However, the same position would lead you to win if it was black to move (Zugzwang).

The basic theory for you to promote the pawn when the opponent king is having the opposition is you need to have your king in front of your pawn 2 ranks ahead of the pawn, (i.e. if pawn's on e3 King needs to be on e5) (opposition means - being right in front of the king when its his opponent's turn to move, for example- in your position black has gained the opposition with white to move), lets say in the same case, its black to move, that means white has the opposition and after black moves to lets say Ke8, e7 wins you the games as the king now has only 1 square to move that is Kd7, now as it is your turn to move, you play Kf7 and gain the opposition again in front of black king Kd7(sideways), so now black can't play Ke8 and you can promote the pawn and win the game.



In this game it's White to move and he gains opposition and put Black King in Zugzwang. (Make sure to read comments for the moves appearing in the box below each game)

[Date "????.??.??"]
[Result "*"]
[FEN "8/8/8/4k3/8/8/3KP3/8 w - - 0 1"]

1.Ke3 { Gaining opposition and putting Black king in zugzwang, so black king has to move and give up one of the key squares which is d4, e4 or f4. } ( 1.Kd3 {This is a blunder as now it will just be a draw } Kd5 2.e3 ( 2.e4+ Ke6 3.Kd4 Kd6 4.e5+ Ke7 ) 2...Ke5 3.e4 Ke6 4.Kd4 Kd6 5.e5+ Ke7 6.Kd5 Kd7 7.e6+ Ke8 8.Kd6 ( 8.Ke5 Ke7 9.Kf5 Ke8 10.Kf6 Kf8 11.Ke5 ( 11.Kf5 Ke8 12.Ke5 Ke7 ) 11...Ke7 ) 8...Kd8 9.e7+ Ke8 10.Ke6 ) 1...Kd5 { If Ke6, then white plays Ke4 and gains opposition again. } 2.Kf4 Ke6 ( 2...Kd6 3.Kf5 Kd5 4.e4+ Kd6 5.Kf6 Kd7 6.e5 Ke8 7.Ke6 ) 3.Ke4 Kf6 4.Kd5 Ke7 5.Ke5 Kd7 6.Kf6 Ke8 7.e4 Kf8 ( 7...Kd7 8.e5 Ke8 9.Ke6 Kf8 10.Kd7 ) 8.e5 Ke8 9.Ke6 Kd8 10.Kf7 Kd7 11.e6+ Kd8 12.e7+ Kd7 
*




Here White King is only 1 rank ahead of the pawn and if black can gain the opposition, game will be a draw. It is Black To move and Black gains the opposition and draws.

[Date "????.??.??"]
[Result "*"]
[FEN "8/8/8/3k4/8/4K3/4P3/8 b - - 0 1"]

1...Ke5! { Now White has no way to gain back the opposition while being ahead of the pawn. } 2.Kf3 Kf5 3.e4+ Ke5 4.Ke3 Ke6 5.Kf4 Kf6 6.e5+ Ke7 ( 6...Ke6 { Also Playable } 7.Ke4 Ke7 { Both the same. } ) 7.Kf5 Kf7 8.e6+ Ke8 9.Kf6 Kf8 10.e7+ ( 10.Ke5 Ke7 ) 10...Ke8 11.Ke6 
*




But if White is 2 ranks ahead of the pawn, then he can win the game even if black has the opposition as he has to give up the opposition soon as shown below.

[Date "????.??.??"]
[Result "*"]
[FEN "8/8/4k3/8/4K3/8/4P3/8 w - - 0 1"]

1.e3 { Now Black has to give up one of the key squares which is d5, e5 or f5. } 1...Kd6 2.Kf5 { And after this White wins as shown in above example. } 
*