Image copyright Getty Images Image caption Donald Trump suggested he would reassess US treaties with longstanding allies

Donald Trump has said that if he is elected president he may abandon a guarantee of protection to fellow Nato countries.

Speaking to the New York Times, Mr Trump said the US would only come to the aid of allies if they have "fulfilled their obligations to us".

Members of Nato have all signed a treaty that says they will come to the aid of any member that is attacked.

Mr Trump will speak on Thursday at the Republican National Convention.

In a preview of what he will tell convention-goers in his speech, he outlined a foreign policy strategy aimed at reducing US expenditure and involvement abroad.

What the world wants to know about Trump - Q&A from Cleveland

Although the White House has not responded directly to Mr Trump's comments, spokesman Josh Earnest said on Thursday the US commitment to NATO was "ironclad".

He said potential enemies should not misjudge Washington's commitment to defend its NATO allies.

"The president renewed that commitment just two weeks ago today when he travelled to Warsaw, Poland, to attend the NATO summit."

Analysis: Jonathan Marcus, BBC defence and diplomatic correspondent

Image copyright AFP Image caption The idea that the US might become an unreliable ally is a nightmare for Nato's European members

Mr Trump's comments hit at the fundamental basis of the Atlantic alliance; that an attack on one ally is an attack on all.

Under Article 5 of Nato's founding treaty, allies are bound to come to the aid of a member under attack.

The US has long been pressing its European allies to spend more on defence. That is slowly beginning to have an effect.

But never has there been a suggestion that the US would renege on its responsibilities.

His comments on Turkey suggest that the Republican contender also seems reluctant to insist upon Nato members maintaining strong democratic principles.

Mr Trump's positions will be seen by Washington's Nato partners as at best eccentric and at worst alarming.

At a time of growing tensions with Moscow, the idea that the US might become an unreliable ally is a nightmare for Nato's European members.

Asked about Russian aggression towards Nato countries in the Baltic region, Mr Trump suggested the US might abandon the longstanding protections offered by the US to such nations.

The divisive Republican candidate also said that, if elected, he would not pressure US allies over crackdowns on political opposition and civil liberties, arguing that the US had to "fix our own mess" before "lecturing" other nations.

He said: "Look at what is happening in our country. How are we going to lecture when people are shooting policemen in cold blood?"

Asked about the failed coup in Turkey on Friday, the Republican candidate praised Turkish president Recep Tayyip Erdogan, who has been criticised by some Western leaders over his increasingly authoritarian rule.

"I give great credit to him for being able to turn that around," Mr Trump said of the failed coup. "Some people say that it was staged, you know that," he said. "I don't think so."

US Secretary of State John Kerry has urged Mr Erdogan to follow the rule of law, amid a crackdown on opposition figures by the Turkish leader in the wake of the coup attempt. But Mr Trump chose not to make a similar statement.

"When the world sees how bad the United States is and we start talking about civil liberties, I don't think we are a very good messenger," he said.

Image copyright AP Image caption Mr Trump will address the Republican National Convention on Thursday

The Republican candidate also said that he would reassess the costs to the US of longstanding defence treaties, potentially forcing allies to take on those costs.

He said he would "prefer to be able to continue" existing agreements - but not if he felt allies were taking advantage of the US.

Referring to what he said were US trade losses, Mr Trump said: "We are spending a fortune on military in order to lose $800bn. That doesn't sound very smart to me."

He also suggested he would close US bases abroad. "If we decide we have to defend the United States, we can always deploy" from American soil, he said "and it will be a lot less expensive".

Mr Trump will address the convention on Thursday following speeches from his running mate, Governor Mike Pence and his wife Melania Trump.

Mrs Trump's speech caused embarrassment when journalists noticed that sections of the text appeared to have been copied directly from a speech given by Michelle Obama at the 2008 Democratic Convention.

Senator Ted Cruz, who came second in the Republican primaries, was booed by convention-goers on Thursday after opting not to endorse Mr Trump in his speech.