Fifty-one members of the 90-seat parliament voted in favor of his candidacy, while 36 voted against it.
Jansa now has 15 days to submit the composition of the new government to the National Assembly for approval.
His appointment has put an end to the political crisis in Slovenia that had persisted since the parliamentary elections in March.
Slovenian Prime Minister Robert Golob has appealed to the President of the European Commission with an urgent request to investigate the activities of the Israeli private intelligence company Black Cube.
During a meeting on Friday, the Slovenian government officially approved a decision to provide financial assistance to Ukraine.