By Rodi Said and Tom Perry

HASAKA, Syria/BEIRUT (Reuters) - Syrian Kurdish forces took near complete control of Hasaka city on Tuesday as a ceasefire ended a week of fighting with the government, consolidating the Kurds' grip on Syria's northeast as Turkey increased its efforts to check their influence.

The Kurdish YPG militia, a critical part of the U.S.-backed campaign against Islamic State, already controls swathes of northern Syria where Kurdish groups have established de facto autonomy since the start of the Syria war in 2011.

Their growing sway has alarmed Turkey, which is fighting an insurgency among its own Kurdish minority.

Syrian rebels backed by Turkey said they were in the final stages of preparing an assault from Turkish territory on the Islamic State-held Syrian border town of Jarablus, aiming to preempt any YPG attempt to take it.

"We will give every kind of support to the Jarablus operation. This is important for our own security," Turkish Foreign Minister Mevlut Cavusoglu told a news conference.

The battle over Hasaka marked the most violent confrontation between the YPG and Damascus in more than five years of civil war, with the Syrian air force used against the U.S.-backed Kurdish forces for the first time last week.

On Tuesday, Hasaka's remaining government officials were confined to a few buildings known as the security quarter, while the rest of the city was under Kurdish control. The Kurds held around 70 percent of Hasaka prior to the latest fighting.

"Even if they (pro-government militias) keep a symbolic presence, it is a big defeat for the regime in Hasaka," said Rami Abdulrahman, director of the Syrian Observatory for Human Rights, which reports on the war.

The terms of the ceasefire that came into effect at 2 p.m. on Tuesday included the withdrawal of the Syrian army and allied militia from Hasaka city, Kurdish officials said.

The YPG would hand over all seized areas to an affiliated Kurdish police force, the Asayish. Government policemen would be left to secure the one remaining area under state control.

Details reported by state TV included a prisoner swap, handing over the wounded and bodies of the dead, and opening the roads to Syrian army positions inside and outside the city.

Reuters could not immediately obtain a full text of the agreement. One of the Kurdish officials said the deal was concluded on Monday evening "via international parties".

In Washington, the U.S. State Department said U.S.-Russian talks about establishing a separate, nation-wide cessation of hostilities in Syria were making progress.

"We continue to make headway. We're not quite there yet," department spokesman Mark Toner told reporters, offering a more upbeat view than Secretary of State John Kerry gave on Monday.

Speaking at a news conference in Nairobi, Kerry had said "it is my hope that we are reaching the end of those discussions one way or another" but added he was voicing hope, not optimism.

REBELS READY ATTACK

YPG-controlled areas of northern Syria include an uninterrupted 400 km (250 mile) stretch of the Syrian-Turkish border from the eastern frontier with Iraq to the Euphrates river, and a pocket of territory in northwestern Syria.

Turkey is focused on preventing the YPG or its allies building on recent advances against Islamic State by capturing the town of Jarablus. The U.S.-backed Syria Democratic Forces alliance (SDF), including the YPG, captured the city of Manbij, just south of Jarablus, from Islamic State earlier this month.

Turkish Deputy Prime Minister Numan Kurtulmus told broadcaster NTV that northern Syria should not become the domain of one group alone and that a "secure zone", an internationally policed buffer area Turkey has proposed in vain in the past, should be reconsidered.

Turkey has been shelling Islamic State positions in Jarablus as part of an effort to help allied Syrian rebels secure it. Rebel sources say they have been mobilizing in Turkey, ready to cross into Jarablus.

Authorities in Karkamis, the Turkish town across from Jarablus, offered residents free transport to leave after repeated shelling from the Syrian side of the border.

At least seven mortars landed in the town, a Reuters witness said, while a drone hovered overhead and armored military vehicles patrolled the border. Broadcaster CNN Turk showed live footage of people leaving Karkamis, which the correspondent described as a ghost town.

A Syrian rebel with one of the Turkey-backed groups said the fighters were waiting for the signal to enter Jarablus.

"The Turkish artillery has not stopped ... this is to create the right atmosphere to start the battle of liberating Jarablus," said the rebel, who declined to be identified.

A second rebel familiar with the preparations said around 1,500 fighters were now gathered at a location in Turkey to take part. "The plan is to take Jarablus and expand south ... so as to abort any attempt by the Kurds to move north ... and so that Kurds don't take more villages," he said.

The leader of the newly declared "Jarablus military council", set up with the aim of mounting its own campaign to seize Jarablus with SDF support, was assassinated on Monday, the Observatory said. A Kurdish official said two "agents of Turkey" had been detained over the killing.

(Additional reporting by Suleiman al-Khalidi in Amman, Daren Butler and Asli Kandemir in Istanbul, Umit Ozdal in Karkamis, Turkey and David Alexander and Arshad Mohammed in Washington; Editing by Dominic Evans and Alistair Bell)