Kurdish forces are on the brink of capturing the last town under Isis control in Syria – but before that battle is over they might have to face a Turkish invasion.

The town of Hajin, on the banks of the Euphrates river in eastern Syria, is Isis’s last holdout in the country. After three months of intense fighting, the Kurdish-led Syrian Democratic Forces (SDF) announced on Friday that it had taken most of the town.

The capture of Hajin would represent a milestone for the SDF, which for the last four years has been the west’s main ally in the fight against Isis in Syria. With the backing of the US and UK, it has forced Isis from swathes of the country’s north and east to this small pocket in Deir Ezzor.

That alliance could soon be put to the test, however, as Turkey’s president Recep Tayyip Erdogan vowed this week to launch a military operation against those same fighters. The move has placed Washington in the middle of two allies – one a Nato member and regional heavyweight, and the other a key partner in the fight against Isis.

Ankara has long complained about US support for the YPG, a Kurdish militia that makes up the vast majority of the Syrian Democratic Forces. Turkey considers the group a terror organisation, and has watched as it has grown in strength since the onset of the Syrian civil war. It fears a powerful Kurdish group on its border will threaten its efforts to contain Kurdish nationalism within Turkey.

Mr Erdogan said on Wednesday that Turkey would launch an operation against the YPG “in a few days”. He added that it was “time to realise our decision to wipe out terror groups east of the Euphrates.”

Mr Erdogan has made similar threats before, but it will not be the first time Turkey has crossed the border to fight the YPG. In March, the Turkish army and allied Syrian rebel groups took control of the majority Kurdish province of Afrin, which had been controlled by the group.

A spokesperson for a Turkish-backed Syrian rebel group said on Thursday that 15,000 fighters are preparing to join the latest operation. Turkish state media has been dominated by reports of the impending offensive.

The US has some 2,000 of its own troops stationed in the Kurdish areas of northern Syria in support of the SDF, and the Turkish threats prompted a forceful response from the Pentagon on Wednesday.

Commander Sean Robertson, a Pentagon spokesperson, said an operation to cross the border would be “unacceptable”.

Syrian refugee in Lebanon: Education is the foundation of my dreams Show all 14 1 /14 Syrian refugee in Lebanon: Education is the foundation of my dreams Syrian refugee in Lebanon: Education is the foundation of my dreams Sara, 11, is a Syrian refugee living in Lebanon’s Bekaa Valley in an informal tented settlement. She attends UNRWA-funded Jefna school where she is top of her class and regarded as the brightest child in the school by her teachers Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara helps her mother Fatima around the house watering the pot plants, washing the concrete ﬂoors and helping to prepare the meals in the kitchen Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Behind the family tent is an old disused quarry where the Bedouins’ sheep graze the hard thistle plants. Sara can see across the Bekaa Valley to the mountains, beyond which is Syria and the distant memories of the old life they had Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara is keen to leave the tent, which leaks water from the roof when it rains and in the freezing cold winter months the snow drifts in. She dreams of having a nicer home Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams She spends almost all her time in the tent when not at school: her brothers Ali and Deeb won’t let her play football with them Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Hadi, 2, is taught some basics of English by Sara to prepare him for enrolment into an UNRWA school when he is 6. Unlike the others, Hadi was the only one born into tent life. He cares for the stray dogs that visit the settlement and plays with the abundance of stones in the old quarry Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Deeb accompanies Sara to buy bread from a small shop run from a neighbours home. Sara’s family cannot aﬀord to buy luxuries like meat on the $260 per month cash vouchers they receive from UNRWA and therefore their meals only consists of rice, potatoes and salad Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara is a beneﬁciary of Educate A Child, a programme of the Education Above All Foundation. As well as core curriculum subjects, she is also receiving psychosocial support to assist her with any trauma she may have been exposed to while ﬂeeing their homes from the civil war in Syria Photos Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara and her family visit Beirut on our ﬁnal day in Lebanon. It was Sara’s ﬁrst time on an escalator and, after being cautious at ﬁrst, she soon found her feet and was leading her family around the city with conﬁdence Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams When she eventually leaves Lebanon to continue her studies and pursue her dream of becoming a doctor, she imagines the cities will be big and beautiful just like Beirut Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Ali and Sara have never seen the sea, let alone stood on its shores and played in the shallow water. Her brothers are now inviting their sister to come and play with them, which is very unlike things are back home in the tent where Sara’s place is indoors helping with chores Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara, Ali and Deeb chase the white water on Lebanon’s coastline. As the waves break on the sand, so too do the barriers between siblings. They laugh together and have forgotten about their struggle for now Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams At 11 years old, Sara could never have imagined becoming a refugee. Sitting on a swing in Beirut, she hopes for a better future built on a good education and psychosocial support made possible by EAA and UNRWA Paddy Dowling Syrian refugee in Lebanon: Education is the foundation of my dreams Sara has dreams of moving to Canada, Europe or the Gulf states where she can study in English and eventually become a doctor. She didn’t ask to be a refugee and refuses to give up her ﬁght for a better life. Sara wants to be able to contribute to a society by becoming a doctor to help others Paddy Dowling

“Unilateral military action into northeast Syria by any party, particularly as US personnel may be present or in the vicinity, is of grave concern,” he said.

Both the US and the SDF have warned that an attack against Kurdish areas of northern Syria will allow Isis a chance to regroup. And although the extremist organisation may be close to losing the last of its territory, it is already transforming back into an insurgency that will require Kurdish forces to counter it.

A statement released by Syria’s main Kurdish parties on Friday called Turkey’s threats a “declaration of war”, adding that “all the forces in north and east Syria ... are asked to agree on strategies to confront this aggression”.

In November, the SDF temporarily suspended its offensive against Isis in Hajin after Turkey fired shells across the border. Its top commander has threatened to do the same again if Turkey attacks.

“If there is a Turkish attack, the YPG forces will be forced to come protect the borders, to defend their families,” General Mazloum Kobani said on Thursday. He added that “the battle against Daesh is not possible” without them.

Following the shelling last month, the US set up observation posts along the border where Turkish and YPG positions face off in an effort to reduce tensions.

While diplomatic efforts were underway to prevent an outbreak of fighting on the Turkey-Syria border, the SDF said it had captured most of Hajin on Friday, and would finish off the last holdouts in the town within days.

Support free-thinking journalism and attend Independent events

Beyond Hajin lies a string of smaller villages on the eastern banks of the Euphrates. The SDF estimates that some 5,000 Isis fighters remain in that last pocket, which it will capture in the “coming weeks”, according to SDF commander Lilwa al-Abdullah.

The operation has been one of the toughest battles faced by the SDF. Whereas in previous battles Isis has made deals to retreat to other areas, there is nowhere else to escape to from Hajin. And because it is its last holdout, the battle is being led by its most experienced fighters.

As a result, there have been significant casualties on both sides. The UK-based Syrian Observatory for Human Rights said that some 793 Isis fighters have been killed since the beginning of the operation to take Hajin in mid-September, while 464 SDF fighters have died.

There have been significant civilian casualties too. Much like in previous battles to recapture towns in which Isis is entrenched, the coalition has relied heavily on its superior air power.