Keeping in mind that it's illegal to make a move that leaves your own king up for capture by an enemy piece:
Stalemate occurs when a player has no legal moves available on his turn but his king isn't in check. The game ends in a draw.
Checkmate occurs when a playersplayer has no legal moves available on his turn and his king is in check. The game ends in a loss for the checkmated player.
So as a quick tip if you're playing against a lonely king always make sure to leave him one square available to go or to keep him in check to avoid stalemate.