Voters in South Korea elected Moon Jae-in on Tuesday, turning out in large numbers to pick a new president after the ouster in March of Park Geun-hye, who was forced from office in a corruption scandal.

The victory by Mr. Moon, a liberal, capped a remarkable national drama in which the scandal left the conservative establishment in disarray and its former leader in jail. It also set up a potential rift with the United States over the North’s nuclear weapons program.