Background The conventional treatment strategy for patients with atrial fibrillation who are to undergo electrical cardioversion is to prescribe warfarin for anticoagulation for three weeks before cardioversion. It has been proposed that if transesophageal echocardiography reveals no atrial thrombus, cardioversion may be performed safely after only a short period of anticoagulant therapy. Methods In a multicenter, randomized, prospective clinical trial, we enrolled 1222 patients with atrial fibrillation of more than two days' duration and assigned them to either treatment guided by the findings on transesophageal echocardiography or conventional treatment. The composite primary end point was cerebrovascular accident, transient ischemic attack, and peripheral embolism within eight weeks. Secondary end points were functional status, successful restoration and maintenance of sinus rhythm, hemorrhage, and death. Results There was no significant difference between the two treatment groups in the rate of embolic events (five embolic events among 619 patients in the transesophageal-echocardiography group [0.8 percent]) vs. three among 603 patients in the conventional-treatment group [0.5 percent], P=0.50). However, the rate of hemorrhagic events was significantly lower in the transesophageal-echocardiography group (18 events [2.9 percent] vs. 33 events [5.5 percent], P=0.03). Patients in the transesophageal-echocardiography group also had a shorter time to cardioversion (mean [±SD], 3.0±5.6 vs. 30.6±10.6 days; P< 0.001) and a greater rate of successful restoration of sinus rhythm (440 patients [71.1 percent] vs. 393 patients [65.2 percent], P=0.03). At eight weeks, there were no significant differences between the two groups in the rates of death or maintenance of sinus rhythm or in functional status. Conclusions The use of transesophageal echocardiography to guide the management of atrial fibrillation may be considered a clinically effective alternative strategy to conventional therapy for patients in whom elective cardioversion is planned.