The protocol distributed systems use to pick a single coordinator, the foundational primitive behind every consensus and HA system.
Leader election is the algorithm a group of distributed nodes uses to pick exactly one of them as the leader (primary, coordinator, master). The leader does the writes, manages locks, runs the cron, and the others wait in line as standby. When the leader dies, a new election picks a successor. Common implementations use ZooKeeper, etcd, Consul, or Raft directly. The hard cases are split-brain (two nodes think they're leader) and stale-leader (a partitioned leader keeps writing to its side of the network).
Leader-election bugs are some of the worst outages in distributed systems: split-brain causes data divergence, stale leaders cause silent data loss, repeated re-elections cause availability to oscillate. Using a battle-tested coordinator (etcd, ZooKeeper) instead of rolling your own is a near-universal best practice. Even then, plan and test how the system behaves during an election, the seconds-long window when there's no leader.
See the part of the platform that handles leader election in production.