Slovenia Again in Political Crisis
The vote came after a six-hour congress, in which Bratušek and Janković faced off with different visions on cooperation in the current coalition and views on economic policy.
"It would appear that there is still a relationship to the father of this party," Janković said after the vote. Earlier he had appealed for PS to return to its roots.
The outcome of the PS leadership battle was highly anticipated because of its broader implications for Slovenian politics.
The three partners of the PS in the ruling coalition have said they would not work with Janković in government.
This was immediately confirmed by the coalition Citizens List (DL), which said in a statement after the end of the congress that it wanted an agreement to be reached on early elections as soon as possible.
However, Janković reiterated that he would like Bratušek to stay on as PM in his brief acceptance speech, maintaining that this should be possible.
"I would like us to leave this room more united than we came," he said, adding that the weekend was "a chance for reflection" and calling on Bratušek "not to take any decisions".
The prime minister has said that she would resign if ousted as party leader, but made no announcement on this after the defeat.
She was brief in her concession speech, saying she wished Janković "will be able to achieve everything you have said here today".
In a subsequent tweet, she thanked her supporters and said she was "proud of what we have achieved".
Meanwhile, MP Peter Vilfan said the prime minister would now take a few days to reflect before making her announcement next week, likely on Tuesday. But he added that he did not expect the prime minister to stay on.
He added that PS would like to become the first party in Europe to oust its own government.
Other MPs were more reserved, calling for dialogue on how to proceed and saying it was not necessary that the government would have to leave office.
Janković for his part said that the parties which had threatened to leave the government should he be elected must be made to take the first step.
"I maintain that I can help the government by demanding greater implementation of [PS's] Slovenia 2020 programme in coalition deals," said Janković.
"As long as we stay united, we can be a force of hope for Slovenia," he said, adding that the combination of Bratušek's "women's subtlety" and his "inability for excessive negotiations" could be a perfect match for the country.
Addressing nearly 800 party members earlier at the congress, Janković suggested that the party had strayed too far from its platform in the current government since it was being extorted by smaller parties.
Singling out the Pensioners' Party (DeSUS) and Citizens' List (DL), the PS founder said that the government was doing too little to restart the economy because the PS was unable to implement its programme, including a list of key state investments.
Bratušek responded by defending the need to reach compromises with coalition partners. "Politics is about nurturing fragile relations in order to build trust with partners that results in progress," said Bratušek.
She maintained that she was true to the party's Slovenia 2020 programme, while arguing that implementing it required time. "Who in this room thinks that 'Slovenia 2020' can be implemented in one year?"
Bratušek said that she called the congress and the leadership vote in order to clear up who was the leader and who set the agenda in the face of increasing infighting regarding policy.
Both challengers indicated that economic policy was a key area of disagreement, as Bratušek blasted opposition to privatisation from within the party. Janković countered by saying that the party had done a U-turn on key issues, such as the bad bank, which it opposed while in the opposition in 2012.
The prime minister defended the economic track record of the government, wondering why the congress was not talking "about the forecast growth for this year, the strong exports, which have risen by 10% this year, and the halving of bond yields since we took office".
Early last year Janković withdrew from the helm of the party he led since it was founded in October 2011 after the anti-corruption commission said he could not account for some of his assets.
His withdrawal was set as a condition by prospective coalition partners to enter a PS-led government, which emerged after the Janez Janša government was ousted from power when the anti-corruption commission established Janša too could not account for some of his assets.