David Cameron has failed to win over his Polish counterpart in his bid to reform welfare rules in the European Union following late-night talks in Warsaw.
The Prime Minister described discussions with Beata Szydlo as "excellent" and said they had agreed to work together to find a solution on the thorny issue of when migrants can claim benefits.
But the Polish prime minister told reporters she did not "see eye-to-eye" with Mr Cameron on the proposals.
In a press conference in the Polish capital, Mr Cameron said: "The challenge is the scale of the vast movement of people we have seen across Europe over the last decade and the pressure that that can put on public services.
"That is the problem we need to address and I believe with the type of political will I have seen here in Poland we can find a way.
"I want Britain to stay in a reformed European Union and the prime minister has made clear that Poland wants Britain to remain in the EU."
The development came after Mr Cameron issued a fresh warning that the migration crisis could push the UK into voting to leave the EU.
The Prime Minister said the short-term impact of the influx of migrants arriving in the EU could be a desire among voters to "push Europe away".
But in a hint that he he might be considering a longer campaign before his promised referendum on EU membership, the Prime Minister said the "longer term reaction" to the twin migration and eurozone crises could be to make sure there was a relationship with Brussels that "works".
His remarks came as the number of migrants claiming asylum in the EU this year officially passed one million, according to Eurostat, the EU's statistics agency.
The Prime Minister was in Poland on the latest leg of his diplomatic offensive to win backing for the reform programme he hopes will allow him to recommend the UK remains within the 28-member bloc.
A major obstacle is his call for a ban on EU migrants claiming in-work benefits in the UK until they have been in the country for four years, which he hopes will act as a disincentive for citizens of member states seeking to come to Britain.
The Polish prime minister said there was a "common direction" and she was hopeful there could be a solution that would keep the UK in the EU.
"However there are also discussions and issues about which we do not see eye-to-eye today," she added.
"But I believe that these issues will be further discussed by us. We will be talking about them, we will try to solve them together in consensus."
Ms Szydlo said her reservations related to the proposals on "the welfare system and child benefits".
The Polish prime minister said she respected the UK's right to take decisions about its welfare system but stressed Mr Cameron had to respect the "basic principle" of freedom of movement for people within the EU.
Mr Cameron said the UK was working "round the clock" on its reform agenda and stressed the importance of the country's EU membership for security.
Mr Cameron said: "We are looking for agreement. We haven't achieved that agreement yet, but I think what you have heard from the prime minister here in Poland and from other leaders is that there is goodwill, there is a wanting to keep Britain within a reformed EU, there's real engagement with the agenda we have set out, a lot of common ground, a lot of agreement on the very significant proposals we have made."
But he acknowledged "some of them are difficult and they need further work".
Mr Cameron insisted there is "meaningful change already under way" but "it is very difficult work, it takes time, which is why I'm not attempting to achieve everything in December, it's going to take longer than that to get an agreement".
"But I am confident that we will get an agreement."
He repeated he would "rule nothing out" if he could not get a deal, indicating he would be prepared to recommend a British exit.
But he insisted the talks in Poland and Romania on his two-day trip had boosted his hopes of a deal.
"What I have found on the many trips I have made to other European countries to discuss these things is there's a lot of goodwill."
He added: "In an age of insecurity and danger and terrorism, Britain brings a lot to the European Union."
Mr Cameron stressed that Britain would not be insulated from the effects of the migrant or eurozone crises if it cut ties with Brussels.
"If Britain was outside the EU we would still be affected by the crisis in the eurozone. If we were outside the EU we would still be very affected by the migration crisis coming out of Syria and Africa.
"So the question for us is, if we can get these reforms that I have set out, will we enhance British power, British prosperity, British security, the safety of British people being inside this reformed organisation or being outside it?'.
"I believe that if we can secure these reforms we will be better off inside."
He continued: "This question has become bigger and more important with the security crisis that we face in Europe. So it becomes all the more important that we work round the clock to deliver this successful renegotiation.
"I believe in the last 24 to 48 hours, with this goodwill - we don't yet have an agreement, it's going to take time - but I think there is the goodwill to reach an agreement that will be of benefit to the British people."