President Trump’s defense secretary on Wednesday warned America’s NATO allies that if they don’t cough up more cash for defense, the US could “moderate” its commitment to the decades-old treaty.

“I owe it to you all to give you clarity on the political reality in the United States, and to state the fair demand from my country’s people in concrete terms,” James Mattis said.

“America will meet its responsibilities, but if your nations do not want to see America moderate its commitment to the alliance, each of your capitals needs to show its support for our common defense.”

The threat came during a closed-door meeting with top defense officials from America’s closest historic allies, and follows through on a Trump ultimatum that all 28 NATO members pay more for their own defense.

All NATO allies pledged to spend at least 2 percent of their gross national product on defense, but some don’t — the source of a long-standing complaint from Washington.

Trump has ramped up the criticism of NATO — a treaty signed after World War II by Western European nations as a defense against the Soviet Union and other potential enemies.

The president called the alliance “obsolete” on the campaign trail, a comment that rattled the UK, France and Germany but was music to the ears of Russian strongman Vladimir Putin.

Mattis, a retired Marine general who served as NATO’s supreme allied commander of transformation from November 2007 to September 2009, recalled that then-Defense Secretary Robert Gates warned NATO nations that Congress and the American people “would lose their patience for carrying a disproportionate burden” of the defense of allies, the Wasington Post reported.

“No longer can the American taxpayer carry a disproportionate share of the defense of Western values,” Mattis said.

“Americans cannot care more for your children’s security than you do. Disregard for military readiness demonstrates a lack of respect for ourselves, for the alliance, and for the freedoms we inherited, which are now clearly threatened.”

Only five of NATO’s 28 countries spend at least 2 percent on defense — the UK, Poland, Greece, Estonia and the US.

Mattis’ remarks come as pro-Russian rebels in eastern Ukraine have escalated their battle with government forces.

Russia had previously invaded and annexed Crimea, an incursion that NATO countries criticized but did nothing concrete to stop.