A logical clock is a way for the computers in a distributed system to agree on the order in which events happened, even though each machine has its own imperfect physical clock and no two clocks are ever exactly synchronized. Instead of measuring real time, a logical clock just counts events.
Leslie Lamport described the mechanism in his 1978 paper “Time, Clocks, and the Ordering of Events in a Distributed System.” Each process keeps a single counter. The counter is incremented before each event the process performs. When a process sends a message, it attaches its current counter value as a timestamp. When a process receives a message, it sets its own counter to be greater than both its previous value and the timestamp carried in the message, then increments again.
This simple rule guarantees that if one event could have caused another, the causing event always carries a smaller clock value. That gives a consistent ordering that every process can agree on, which is enough to coordinate actions such as granting a resource to whichever request has the lowest timestamp.
Logical clocks have a known limitation: a smaller counter value does not prove that one event actually influenced another, only that it is consistent with having done so. Two unrelated events on different machines can receive ordered timestamps even though neither caused the other. Vector clocks were later developed to capture that distinction more precisely.