Supporters of the “yes” vote erupted in celebration in the Irish capital of Dublin on Saturday, when results of the referendum on legalizing abortion showed that it had passed by a surprising landslide.

Excited crowds of smiling “yes” voters clapped, cheered and burst into song as they filled the courtyard outside Dublin Castle, a government complex, to await the release of the final tally. As evening approached, officials announced that the measure had been approved by more than 66 percent of voters.

“No” supporters lamented what they saw as a devastating loss for the country.

The vote repeals the Eighth Amendment of the Constitution — a 1983 measure that gave equal rights to a fetus and a woman and banned abortion under almost all circumstances. The government has announced plans to pass legislation by the end of the year to allow for unrestricted terminations for pregnancies up to 12 weeks.