Before taking office, Donald Trump had called NATO "obsolete".

NATO Secretary General Jens Stoltenberg said Sunday that US President Donald Trump's regular complaints about the alliance had not undermined it -- adding that his criticism on defense spending was having a positive impact.

Trump has frequently blasted members of the 29-nation western security partnership for not paying more into their national defense budgets.

Before taking office, he called NATO "obsolete" and recent media reports said he spoke to senior officials last year about pulling out.

"President Trump has been very clear, he is committed to NATO. He stated that clearly just a few days ago and also at the NATO summit in July," Stoltenberg said on "Fox News Sunday."

"But at the same time, he has clearly stated that NATO allies need to invest more. And therefore at the summit in July last year, we agreed to do more to step up -- and now we see the results."

NATO members agreed in 2014 to spend two percent of their gross domestic product on defense by 2024 but around half are not on course to make that target.

Stoltenberg said, however, that by the end of 2020, NATO allies would have added $100 billion extra toward defense spending.

"So we see some real money and some real results. And we see that the clear message from President Trump is having an impact," he added.

"NATO allies have heard the president loud and clear and now NATO allies are stepping up. So this is good news meaning that we actually see more fair burden sharing."

Earlier this month Trump repeated his view that close allies had been taking advantage of the US security umbrella for decades and that it was his mission to stop that.

"We cannot be the fools for others. We cannot be. We don't want to be called that. And I will tell you for many years behind your backs, that is what they were saying," he said during an address to the Pentagon.

The president acknowledged Stoltenberg's positive feedback soon after the interview aired, tweeting that sharing defense costs had made NATO "more united."

"Dems & Fake News like to portray the opposite!" he added.

Stoltenberg was in Washington for meetings with Secretary of State Mike Pompeo, acting Defense Secretary Pat Shanahan and national security advisor John Bolton.