David Cameron has said the UK and Turkey are working "hand in glove" to prevent British jihadists returning home after fighting in Iraq and Syria.
Speaking after talks with his Turkish counterpart in Ankara, the UK prime minister said Islamic State (IS) was a "common enemy" that must be confronted.
He hailed the countries' existing intelligence co-operation and said this would be stepped up further.
The US and EU want Turkey to take a more active role in tackling IS.
At a press conference in the capital, Turkey's prime minister Ahmet Davutoglu said the two countries shared a "strong and common political will" to address the threat posed by foreign fighters travelling to and from conflict zones in Syria and Iraq.
Mr Cameron said that British jihadists had "sometimes" passed through Turkey and the two men had had "productive discussions" over how they could be detained and, if possible, prosecuted.
The UK government is seeking greater powers to confiscate the passports of people returning to the UK from Iraq and Syria who are thought to pose a threat to national security, with Parliament currently debating changes to the law.
Asked whether Turkey could be doing more to identify and stop suspects at its borders, Mr Cameron said the two countries were already working "as closely as we possibly can" to tackle the threat.
He said: "Whether it is about stopping people coming through Turkey to Syria or Iraq to fight for Islamic State, whether it's about making sure we deal with people when they return, whether it is the highest levels of intelligence co-operation that we can possibly achieve between our countries, this is all about making sure people are safer in Turkey and making sure people are safer back home in the UK."
As well as addressing the "extremist ideology" that fuels Islamic State, he reiterated his calls for a transition to a more democratic and representative government in Syria and more efforts towards reconciliation by the new government in Baghdad.
Mr Cameron also hailed a growth in economic links between the UK and Turkey, saying bilateral trade had increased by 60% since 2010.
Making his first visit to Turkey since 2010, Mr Cameron will later be hosted at a dinner by president Recep Tayyip Erdogan.
Mr Cameron will not return to the UK in time for Prime Minister's Questions on Wednesday, with Liberal Democrat Deputy Prime Minister Nick Clegg expected to step in for him.