Captain Robert Koren set them on their way in the 19th minute and Aleksander Radosavljevic ensured they took a comfortable lead into the break.
The hosts leap into third spot in Group 3, two points behind Northern Ireland and four behind leaders Slovakia, who have a game in hand. San Marino remain rock bottom with zero points having conceded 37 goals in eight games.
Matjaz Kek's team started lively, but failed to score until the 19th minute when Ljubijankic's cross fell to Koren and the captain fired his side into the lead.
Slovenia were by far the better team but had to wait until six minutes from the break to double their advantage when Radosavljevic headed home Bojan Jokic's cross.
Ljubijankic, who had been denied several times before the break. had two more chances at the beginning of the second half, but could not find the back of the net. Slovenia's luck changed in the 54th minute when second half substitute Kirm headed in Miso Brecko's corner.
Koren doubled his tally 20 minutes later with a stunning strike from the edge of the area into the top left corner. The West Brom midfielder almost added another in the final minute, dribbling past three defenders, only to lob the ball over the bar.
There was still time for a fifth, however, as Ljubijankic headed in a cross from Milivoje Novakovic in the third minute of added time.