An implantable medical device (IMD) having a therapy circuit for delivering atrial pacing and a control circuit for detecting a return to sinus rhythm. The control circuit determines the duration of an atrial arrhythmia preceding the return to sinus rhythm, and controls the therapy circuit to deliver transient atrial pacing based on the atrial arrhythmia duration.