Base64 encoding works by dividing data into chunks of 6 bits and then mapping each chunk to a character from a predefined 64-character set. This includes uppercase and lowercase letters, digits, '+', and '/'. Padding with '=' ensures the final output's length is a multiple of 4.