Spam filtering is a technique used to identify and block unwanted or unsolicited email messages, commonly known as spam, from reaching a user's inbox. It employs various algorithms and rules to analyze the content, headers, and sender information of emails to determine their likelihood of being spam. This process helps maintain a cleaner inbox and protects users from potential phishing attacks and malicious software.