US Defense Secretary Jim Mattis said on Wednesday that NATO allies must increase defence spending by the end of the year, or the US will "moderate its commitment" to NATO.

He did not elaborate on what the US might do if NATO members failed to fall into line.

Echoing a demand made by President Trump during the campaign, Mattis said NATO should set milestone dates for governments to meet the military funding commitment of spending 2 percent of GDP on defence.

The Pentagon chief said it was a "fair demand" based on the "political reality" in Washington.

"No longer can the American taxpayer carry a disproportionate share of the defense of Western values," he told the alliance's 27 other defense ministers, according to a transcript.

"Americans cannot care more for your children's future security than you do.

"Despite the threats from the east and south, we have failed to fill gaps in our NATO response force or to adapt," he added.

The warning comes after Trump rattled Europe by suggesting the alliance is "obsolete" and that the US may not defend allies who are not willing to fulfill their financial obligations as members of NATO.

There are currently only five countries that meet the spending commitment: The US, Britain, Estonia, Poland and Greece.

The US spends far more on defense than the others combined - in fact, last year it spent 3.61% of GDP on it, according to NATO estimates.

NATO Secretary-General Jens Stoltenberg said that Mattis "expressed a very strong commitment to NATO and to the transatlantic bond".

He added: "We all understand that we are safer and stronger together. A strong NATO is good for Europe and good for the United States and Canada."

He also said that the countries which don't currently meet their commitment had "expressed ambitions, plans" to increase defence spending.