How does the King move and capture?

The king can move one square in any direction. The king can also capture an opponent's piece if it is on one of those squares... assuming of course that the opponent is not defending this piece! The king can NEVER move on to a square that the opponent controls. Doing so would move the king into check.

. . . .

The first example illustrates how the king moves. It can move to any square marked with an "X"

In the second diagram, the king can move to any of the marked squares or capture the black rook because the rook is one square away and is undefended. But the king may not move to one of the squares controlled by the black rook even though the rook is undefended.

In the third diagram, the black rooks defend each other. The white king has only one legal move because the king cannot move to a square controlled by the enemy rooks.

Finally, it is important to add that if the king is under attack (in check), the next move MUST make sure that the attack has been stopped. There are three possibilities. The king must move out of check. Or... the attacking piece must be captured. Or... a piece must be moved between the attacker and the king in order to eliminate the direct attack. If the king is under attack AND there is no immediate way to end the attack, the game is over. CHECKMATE!

Castling

The king is permitted to take part in a very special move, the only chess move that actually involves two pieces at the same time! In the following diagram, the white king can castle on either side of the board. To castle, move the king two squares toward the rook, and then move the rook to the square immediately on the other side of the king.

For castling to be legal, make sure

You may castle if your rook is under attack. You may even castle if your rook passes through a square controlled by your opponent.

Here's where the king and rook end up after castling on each side of the board.

So why castle? See below under the section "King strategy"