At a joint press conference after the meeting in Brdo pri Kranju, Šarec said that given that the security situation was changing rapidly, defence spending had to increase "not only because of NATO but because of ourselves".
The commitments Slovenia made when it joined the alliance 15 years ago and at the summit in Wales in 2014 must also be honoured, he said, but added that the agreed goal of 2% of GDP seemed out of reach at the moment.
While praising Slovenia's contribution to NATO operations in Afghanistan, Kosovo and Latvia, Stoltenberg said he expected the country to do more for "fair burden-sharing" within the alliance.
Slovenia's defence spending is currently around 1% of GDP, which puts it at the bottom among NATO member states.
Šarec therefore assured Stoltenberg that he would strive for defence spending to reach 1.5% of GDP in a few years "if the situation allows it." But he excluded the possibility of raising defence spending to the target of 2% of GDP overnight.
Stoltenberg was also received by President Borut Pahor and parliamentary Speaker Dejan Židan in Ljubljana and addressed the National Assembly.
Pahor told Stoltenberg that he, as the supreme commander of the Slovenian Armed Forces, would continue to strive for "Slovenia to honour its commitments as a NATO member".
Predsednik republike Borut Pahor je na pogovor sprejel generalnega sekretarja Zveze NATO Jensa Stoltenberga, ki se danes mudi na uradnem obisku v Sloveniji. https://t.co/ar9JiMmI0A @NATO pic.twitter.com/05fyv9x9pf— Borut Pahor (@BorutPahor)
Receiving Stoltenberg, Židan meanwhile expressed the awareness that "we must not be egotistical when it comes to security", and that Slovenia should invest in defence.
Before meeting Pahor, the NATO secretary general addressed the National Assembly, calling on the MPs to increase the country's defence spending as they had power to do so as they passed the budget..
He said that increasing defence spending would also be good for Slovenia, while it was not fair to the allies who invest more in the joint defence not to meet the defence spending commitments.
"I urge you invest more. It is in your interest, it is in the interest of us to invest more in our security because we live in a more unpredictable and demanding security environment," he told the lawmakers.
Stoltenberg's address was boycotted by the nine MPs of the opposition Left, with its deputy Primož Siter saying that by visiting Slovenia, the NATO secretary general "is pressuring the country to increase defence spending to 2% of GDP."
Siter said that increasing defence spending was unacceptable. "Slovenia is not under military threat, but it is threatened welfare- and development-wise," he added.
First reactions from the coalition parties to Stoltenberg's call were rather reserved. They said that this was possible in principle, but not to the detriment of other priority areas, including welfare, pensions and the public sector.
A small protest was also held in front of the parliament building against as yet unspecified NATO and US plans to use the port of Koper as a logistics hub.