After meeting party representatives at the royal palace since Tuesday, as is the norm after an election, the king had formally asked the Socialist leader to attempt to form a government with enough backing the assembly to govern, the Spanish parliament's speaker, Meritxell Batet, told reporters.
“It is a task which I assume with honour, with responsibility and with enormous gratitude to the Spanish people,” Sanchez told a news conference.
His Socialists won 120 seats in the 350-seat parliament — three fewer than it won in April — in a repeat general election on November 10 that saw far-right party Vox surge to third place.
Two days after the election, the Socialists signed an agreement with the hard-left party Podemos, which won 35 seats, to form a coalition government in what would be the first such power-sharing deal in Spain's modern history.
But to achieve an absolute majority of 176 seats required to win a confidence vote and be sworn in for another term, Sanchez still needs the support of several smaller parties including Catalan separatists ERC, which won 13 seats in last month's polls, Spain's fourth general election in four years.
The Socialists and the ERC have held talks for several weeks but so far failed to reach an agreement.
The ERC wants to discuss the possibility of holding a legally binding independence referendum in Catalonia, which Spain's central government steadfastly refuses to agree do.
The wealthy northeastern region was rocked by protests, some of which turned violent, after Spain's Supreme Court in October sentenced nine Catalan separatist leaders to lengthy prison terms for their role in a failed 2017 independence bid.
Among those sentenced to jail is ERC leader and former Catalan vice president Oriol Junqueras.
“The negotiations need to be discreet,” Sanchez said.
Since striking a deal with Podemos in November, Sanchez has cooled talk of facing an investiture vote in parliament by Christmas and on Wednesday he did not give a timeframe for when it could take place, saying only that the country “does not have time to lose”.