The confidence vote comes after two inconclusive elections and failed attempts at coalition-building
Mariano Rajoy has won enough votes in parliament to form a minority government as Spain's prime minister.
The conservative leader had needed a majority in the 350-seat parliament during a vote on Thursday but failed so, in Saturday's second attempt, he simply needed more votes in favour than against.
He achieved 170 "yes" votes while 111 politicians voted against him and 68 abstained.
The rival Socialist party had agreed last week to abstain from the second vote, thereby breaking the deadlock.
The confidence vote comes after two inconclusive elections and failed attempts at coalition-building between rival parties but it will still leave Mr Rajoy and his centre-right People's Party facing an uphill struggle to pass legislation.
Mr Rajoy is expected to be sworn in before Spain's King Felipe VI on Sunday.
After the vote he told reporters that he will announce his new cabinet on Thursday and they will be sworn in the following day.
Earlier, hundreds of protesters had voiced their anger at corruption and cuts during Mr Rajoy's first term, shouting: "They don't represent us".
Just hours before the vote, former Socialist party leader Pedro Sanchez, a longtime opponent of Mr Rajoy's who was thrown out in a party rebellion earlier this month, tearfully announced he was quitting parliament.