Spanish Socialist Pedro Sánchez has been sworn in as the country's new prime minister by King Felipe after the ousting of conservative Mariano Rajoy.
Mr Sánchez, who is an atheist, took the oath to protect the constitution without a bible or crucifix - a first in Spain's modern history.
He plans to see out the remaining two years of the parliamentary term.
The Socialist leader won the support of six other parties to remove Mr Rajoy over a massive corruption scandal.
As Spain's new prime minister, whose party only has a quarter of the seats in parliament, he now has to decide who to include in his cabinet and is expected to name them next week.
In a brief ceremony at the royal residence in Madrid on Saturday, Mr Sánchez, 46, promised to "faithfully fulfil" his duties "with conscience and honour, with loyalty to the king, and to guard and have guarded the constitution as a fundamental state rule".
Mr Sánchez brought about the downfall of his predecessor Mr Rajoy by filing a no confidence motion in parliament following a scandal centred on a secret campaign fund that the conservative People's Party (PP) ran from 1999 until 2005.
Mr Rajoy is the first prime minister in modern Spanish history to be defeated in a no-confidence motion.
The new Catalan President Quim Torra, who is a close ally of ousted separatist leader Carles Puigdemont, said that he was committed to continuing the drive for the region's independence from Spain.
Pedro Sánchez emerged as a virtual unknown to win the Spanish Socialist party premiership in 2014. The photogenic economist and former basketball player won members over with a promise to unite a divided party and put the Socialists back in power.
Yet he subsequently suffered two humbling election defeats, in 2015 and 2016. He was eventually forced to resign after his refusal to back Mariano Rajoy in an investiture vote plunged the country into a prolonged political stalemate and his party into bitter infighting.
Months later he confounded his many critics by returning to win the Socialist primary.
Spain's constitution states that the party presenting a no-confidence motion must be prepared to govern and replace the deposed prime minister if a parliamentary majority backs it.
Therefore, this moderate but ambitious 46-year-old from Madrid is now Spain's prime minister, despite the fact that his party commands less than a quarter of seats in Congress.
What happens now?
Stay informed. Subscribe to our newsletter
Mr Rajoy's departure casts the EU's fifth-largest economy into political uncertainty.
Although Mr Sánchez leads the Socialist PSOE party, he is not a member of parliament. Correspondents say that with only 84 lower house seats, the party will struggle to find allies to get legislation enacted.
In return for having backed Mr Sánchez in the parliament vote, Spain's left-wing Podemos (We Can) party is likely to demand significant policy concessions from the PSOE, and perhaps some key cabinet posts.
Mr Sánchez is likely to be challenged strongly over his plan to stick to the Rajoy budget.
Smaller groups - including Basque and Catalan nationalists - supported the no-confidence motion against his Mr Rajoy, but it is unclear whether they will back the new government.
The Ciudadanos party, which had been doing well in opinion polls, supported Mr Rajoy.