A door lock is a mechanical or electrical device that secures a door by preventing it from being opened without the proper key, code, or manipulation. It works by engaging a bolt or latch, which extends into the door frame to physically secure the door. Different types of door locks, like pin-and-tumbler locks, use various mechanisms to ensure secure operation.