MADRID—Mariano Rajoy, a prominent target of the antiestablishment fervor rising across Europe, was assured of re-election as prime minister when his Socialist rivals conceded defeat Sunday, ending Spain’s 10-month leadership impasse.

Socialist leaders, in a reversal, instructed their party’s lawmakers to abstain when Parliament considers his candidacy next weekend, depriving other opposition parties of the votes needed to keep blocking the conservative incumbent. The Socialists, distant runners-up to Mr. Rajoy in two elections...