Socialist leader Pedro Sanchez in the parliament after the motion of no confidence vote.
There were 169 no votes and one lawmaker abstained.
He took the oath of office before King Felipe VI in the Zarzuela Palace near Madrid in the presence of Rajoy just a day after toppling him in a historic no-confidence vote.
Catalonia has sworn in a new government, automatically ending a seven-month takeover by Spain's central authorities following a failed secession bid by the restive region.
"It has been an honor to leave Spain better than I found it", Rajoy said in his final comments as prime minister. Mr. Rajoy was left heading a minority government - with the support of the Ciudadanos Party - and in a precarious position.
"Prime Minister Pedro Sanchez, let's talk, let's address this issue, let's take risks, you and us", Torra said.
Sanchez, who will be Spain's seventh prime minister since the country's return to democracy in the late 1970s, arrives in power after a spectacular turnaround in his political fortunes.
Jury clears deputy in fatal shooting, awards victim's family $4
According to court documents, deputies responded and Hill eventually raised his garage door to answer them, then lowered it again. Newman drew his gun, and as the garage door started to go down, fired four times toward Hill, tracking upward.
Last week, dozens of former PP officials were jailed for money laundering and fraud, and the party fined €240,000 over a kickbacks-for-contracts scheme they ran between 1999 and 2006.
But he will struggle to govern as his Socialists have just 84 seats in the 350-seat parliament. "Hopefully my replacement can say the same thing when the time comes - I hope so for Spain's sake". He told reporters Friday that he was "aware of the responsibility and the complex political moment of our country".
A member of parliament for Catalan pro-independence party Esquerra Republicana de Catalunya (ERC), Joan Tarda, made it clear that his support for Mr Sanchez was motivated by his views on the former PM, rather than the current one.
PP lawmaker Rafael Hernando said Sanchez would be entering the prime minister's office "through the back door" after failing to win any general elections.
He has also pledged to hold an election soon, but is yet to set a date.
And he's already committed to respecting a fiscally conservative budget passed by Rajoy.
Sanchez dialed that back in his speech to parliament on Thursday, saying there was an opportunity for a new understanding on Catalonia although he wanted the region to stay part of Spain.
Although Rajoy survived a similar vote last year, today's ballot draws a line under the 63-year-old's rollercoaster time in office, which began in 2011 and saw him implementing drastic spending cuts before winning re-election in 2015 and 2016.
- Softbank Vision fund invests $2.25 billion in GM self driving cars
- Lottery retailers will be busy as record-breaking Lotto Max draws near
- Trump Says June 12 Meeting With Kim Jong-un Is Back On
- S&P cuts Deutsche Bank rating in latest blow for Sewing's revamp
- Apple Said to Debut Phone-to-Phone Augmented Reality for Greater Privacy
- £2500000 Bugatti Chiron inspires new £330 Lego Technic model
- Roseanne Barr Says She Begged ABC Not to Cancel Roseanne
- Raising The Alarm: Ex-Econ Officials Say Trump Jobs Tweet Needs Investigation
- Lifestyle New Pokemon game coming to a smartphone near you in June
- Malaysia's leader expresses regret over ending MH370 search