Spain’s King Felipe VI has tasked acting prime minister Pedro Sánchez with forming a new government, a complex undertaking that will involve negotiations with diverging parties.

While they won a general election in April and gained lawmakers compared with the previous term, Sánchez’s Socialists failed to secure a majority in parliament and will need the support of other groupings.

But despite the obvious horse-trading that entails, Sánchez is widely expected to get the backing he needs to start his second term as prime minister.

Without the necessary seats in parliament to form a majority, the conservative Popular party, centre-right Ciudadanos (Citizens) and far-right Vox have already resigned themselves to being in opposition.

The Spanish parliament’s speaker, Meritxell Batet, told a news conference on Thursday that the king had asked Sánchez to attempt to create a coalition that can govern.

The monarch has been meeting party representatives at the royal palace since Wednesday, as is the norm after elections.

“It’s a responsibility which I assume with honour,” Sánchez told a news conference.

“There is no possible alternative. Either the Socialist party governs or the Socialist party governs,” he said.

The 47-year-old’s party won 123 seats out of 350 in the general election on 28 April.

“He is profiting from the fact that the opposition is very fragmented, and can’t organise any alternative majority,” said Pablo Simon, a politics expert at Madrid’s Carlos III University.

Negotiations with other parties will not be easy – in all, 17 political groupings are represented in Spain’s fragmented national parliament.

The leftwing coalition Unidas Podemos, with its 42 seats, has already shown its willingness to back Sánchez in the traditional parliamentary confidence vote that follows any general election.

But in exchange, it wants to enter a coalition government.

“What would be most sensible would be if there is a progressive coalition government in Spain … that guarantees political stability for the next four years,” said Podemos leader Pablo Iglesias.

The socialists are not keen on that scenario, preferring to rule alone in a minority government which would seek the support of other parties on a case-by-case basis when passing laws or reforms.

Even with the support of Unidas Podemos, Sánchez will still need other regional parties to get the majority he needs.

He will however try to avoid courting Catalan and Basque separatist lawmakers, which would be likely to lead to accusations that he is putting the unity of Spain in peril.

Two weeks after municipal and regional elections, negotiations have already started at a local level and could also influence which parties decide to give their support or not.

No date for the vote in parliament to elect a PM has been set but it is likely to be in early July, a parliamentary source said.