In Object-Oriented Programming (OOP), a class is the primary mechanism through which encapsulation is implemented. A class allows the bundling of data (attributes) and methods (functions) that operate on that data, controlling access to them. Through encapsulation, data can be kept private within a class and accessed only through public methods, maintaining a clear boundary between an object's internal state and external interaction.