BERLIN—The center-left Social Democrats won an election Sunday in the city-state of Berlin, in a vote that propelled an upstart anti-immigrant party in Germany into its 10th state legislature.

The Social Democrats, led by Berlin Mayor Michael Müller, finished first with 21.6% of the vote, according to a projection based on exit polling and partial vote counts released by public broadcaster ARD. The center-right Christian Democrats, the party of Chancellor Angela Merkel, came in second with 17.5%, followed closely by the radical...