A trigger is a piece of Apex code that executes before or after specific events, such as record insertion, update, or deletion. Triggers are used to automate processes based on these events. On the other hand, a class in Apex is a blueprint for creating objects and can contain variables, methods, and constructors. While triggers handle automatic actions based on record changes, classes encapsulate logic and can be invoked by triggers, other classes, or Visualforce pages.