Europe’s center-left parties, faced with falling support, are shifting left to win back working-class voters lost to hard-left and populist movements—a move that paid off in Spain’s national elections on Sunday, where the Socialists trounced their conservative rivals.

The Socialists, who have governed since last summer, came first in a fragmented field after pitching a platform of workers’ rights, higher taxes on the wealthy and environmental protection—issues central to the party’s social-democratic roots. The party will...