The US has warned Turkey that it has a right to self-defence as the Pentagon confirmed US forces near the town of Kobane came under Turkish artillery fire on Friday evening.

Mark Esper, the US defence secretary, said Turkey risks “serious consequences” by continuing its offensive against Kurdish-held areas in Syria, which came after Donald Trump withdrew US troops from the border this week.

“The explosion occurred within a few hundred metres of a location outside the Security Mechanism zone and in an area known by the Turks to have US forces present,” Navy Captain Brook DeWalt said in a statement.

“The US demands that Turkey avoid actions that could result in immediate defensive action.”

All US troops were accounted for with no injuries after the incident and US forces have not been withdrawn from Kobane, the spokesperson said.

Turkey launches offensive into Syria Show all 25 1 /25 Turkey launches offensive into Syria Turkey launches offensive into Syria Turkish soldiers with armored vehicles EPA Turkey launches offensive into Syria A woman flees with her children during Turkish bombardment on Syria's northeastern town of Ras al-Ain AFP/Getty Turkey launches offensive into Syria Smoke billows following Turkish bombardment on Syria's northeastern town of Ras al-Ain in the Hasakeh province along the Turkish border on October 9, 2019. - Turkey launched an assault on Kurdish forces in northern Syria with air strikes and explosions reported along the border. President Recep Tayyip Erdogan announced the start of the attack on Twitter, labelling it "Operation Peace Spring". (Photo by Delil SOULEIMAN / AFP) (Photo by DELIL SOULEIMAN/AFP via Getty Images) DELIL SOULEIMAN AFP/Getty Turkey launches offensive into Syria The first group of Turkish infantry prepare to enter Syria on the border Getty Turkey launches offensive into Syria Civilians flee AFP/Getty Turkey launches offensive into Syria Smoke billows from targets inside Syria AP Turkey launches offensive into Syria Turkish armoured vehicles enter Syria in Akcakale Getty Turkey launches offensive into Syria Civilians leave as smoke rises from Ras al-Ain AFP Turkey launches offensive into Syria A multi-rocket launcher fires in an unknown location Turkish Defence Ministry via Reuters Turkey launches offensive into Syria People wave as Turkish soldiers prepare to cross the border Getty Turkey launches offensive into Syria Girls stand together in Ras al Ain town Reuters Turkey launches offensive into Syria A woman walks as smoke billows following Turkish bombardment in Syria's northeastern town of Ras al-Ain AFP/Getty Turkey launches offensive into Syria A Turkish army's tank drives down from a truck towards the border with Syria AFP/Getty Turkey launches offensive into Syria Turkish jet taxis on tarmac after returning to a military base in southeast Diyarbakir Reuters Turkey launches offensive into Syria A Turkish armored vehicle drives down a road during a military operation in Kurdish areas of northern Syria EPA Turkey launches offensive into Syria People sit on belongings at a back of a truck as they flee Ras al Ain town Reuters Turkey launches offensive into Syria Turkey-backed Syrian opposition fighters enter Tel Abyad AFP/Getty Turkey launches offensive into Syria Civilians flee AFP/Getty Turkey launches offensive into Syria People flee Tal Abyad North Press Agency/Reuters TV Turkey launches offensive into Syria People wave as Turkish soldiers prepare to cross the border into Syria Getty Turkey launches offensive into Syria Civilians flee with their belongings AFP/Getty Turkey launches offensive into Syria Civilians flee during Turkish bombardment on Syria's northeastern town of Ras al-Ain in the Hasakeh province along the Turkish border on October 9, 2019. - Turkey launched a broad assault on Kurdish-controlled areas in northeastern Syria today, with intensive bombardment paving the way for an invasion made possible by the withdrawal of US troops. (Photo by Delil SOULEIMAN / AFP) (Photo by DELIL SOULEIMAN/AFP via Getty Images) DELIL SOULEIMAN AFP/Getty Turkey launches offensive into Syria Turkish President Recep Tayyip Erdogan, right, speaks with Defense Minister Hulusi Akar, left, as they watch the operation by Turkish forces in Kurdish areas EPA Turkey launches offensive into Syria Smoke rises from the Syrian town of Tal Abyad AFP/Getty Turkey launches offensive into Syria Turkey-backed members of Syrian National Army prepare for moving to Turkey with heavy armed vehicles EPA

At least 30 civilians have been killed in Syria since the Turkish 'Operation Peace Spring' began on Wednesday, the UK-based Syrian Observatory for Human Rights reported on Saturday.

Turkey’s Defence Ministry has said US forces were not targeted and it was returning fire from Kurdish fighters that originated near the base close to Kobane.

“The firing was ceased as a result of the issue being relayed to us by the US,” the ministry said.

Top Pentagon officials have stressed the need for Turkey to avoid endangering US forces inside Syria, which numbered about 1,000 before the offensive began.

Although the US does not plan on firing on Turkey, which is a Nato ally, the Pentagon has noted the US troops’ right to defend themselves.

“Everyone is fully aware that we are the United States military. We retain the right of self-defence,” General Mark Milley, the chairman of the Joint Chiefs of Staff, said.

The White House has also threatened to “shut down the Turkish economy” with sanctions over its military action.

Turkey’s offensive began days after Mr Trump spoke with Recep Tayyip Erdogan, the Turkish president, and ordered US troops to withdraw from northern Syria.

At the 65th Nato Parliamentary Assembly in London on Saturday, Dominic Raab, the UK's foreign secretary, criticised Turkey's military assault and said it risked weakening the fight against Isis.

"Our position is crystal clear. This incursion is wrong. We want to see maximum restraint, and avoid taking our eye off the ball with Daesh (IS)," Mr Raab said.

"My fear is that the risk is that the humanitarian situation ... could be made worse."

Lord Robertson, a former UK defence secretary and secretary-general of Nato, has said Mr Trump’s decision showed the importance of Nato and international military alliances.

“At the moment we are in a situation where the Trump administration's capricious way of dealing with foreign policy has led to complete confusion in the world today and has allowed some very bad actors to take centre stage,” Lord Robertson said.

The Trump administration has been accused by Kurdish leaders and US lawmakers of abandoning its allies by withdrawing troops.

Turkey has said its aim is to defeat the Kurdish YPG militia, who have led the fight against Isis in Syria, and said that the military operation will continue.

More than 100,000 people have been forced to flee their homes since the offensive began on Wednesday, according to the UN.