An interpreter translates the source code into machine code and executes it line by line, while a compiler translates the entire source code into machine code before it can be executed.