Anger with corruption allowed Sanchez to win Friday's no-confidence motion by 180 votes to 169, with one abstention.
The incoming prime minister has outlined that his priorities will be social issues - such as measures to help young people and the elderly - before calling elections, though he hasn't said when there might be a vote.
Spanish Prime Minister Mariano Rajoy (bottom R) acknowledges applause from Popular Party's members of parliament during a debate on a no-confidence motion at the Lower House of the Spanish Parliament in Madrid on June 01, 2018.
However, the support of nationalist and leftist parties in Friday's vote does not necessarily mean they will back Sanchez' government, which could lead to a political stalemate in parliament.
The new PM has promised to call early elections, but has not set a date.
Ciudadanos leader Albert Rivera said the change of government "is not good news for Spain".
Aitor Esteban, a Basque party MP, warned Mr Sanchez: "Your government will be very complicated, weak and hard".
"This is going to be a constant bing, bang, boom".
NBA Finals: Warriors vs
The most orders for Cavs and Warriors conference championship gear came from Cleveland and San Francisco, respectively. Information from ESPN's Dave McMenamin and The Associated Press was used in this report.
He said Mr Rajoy, 63, had failed to take responsibility for his party's involvement, which came to light last week after one of its former treasurers was given a 33-year jail sentence.
"Today we are signing a new page in the history of democracy in our country".
Despite winning the last two votes, he lacked the absolute majority of his first term.
He put Spain back onto the path of growth after a devastating economic crisis although unemployment remains sky-high, jobs precarious and many complain inequalities have risen.
But his term in office was also marred by a series of corruption scandals involving former PP members.
Lawmakers stood and cheered in parliament as the untested 46-year-old - a pro-European lawmaker who has never been in government - became the country's seventh head of government since its return to democracy in the late 1970s.
In its ruling, the court said the credibility of Rajoy's testimony "should be questioned".
The reputation of Rajoy's Popular Party's was badly damaged by a court verdict last week that identified it as a beneficiary of a large kickbacks-for-contracts scheme.
He also hit back by listing the many graft cases involving the Socialists over the years. "With what moral authority do you speak?" he told Sanchez.
- USA set to impose tariffs on steel from Canada, EU, Mexico
- USA firms in China still fear a trade war
- Lions, pumas escape from German zoo; police in pursuit
- M5S, League say Giuseppe Conte's still their man for Italy
- Johnson offers condolences over killing of Russian journalist Babchenko in Kyiv
- Boston Celtics: Marcus Morris shows up when it matters most
- NBA Finals: Golden State Warriors vs. Cleveland Cavaliers preview
- Pompeo confident North Korea summit moving in the right direction
- Serena Williams wears superhero catsuit in French Open return
- Golden State Warriors beat Cleveland Cavaliers in overtime in game one