A pacemaker is a small medical device that generates electrical impulses to regulate the heart's rhythm. It is typically used to treat slow or irregular heartbeats.