David Cameron has signalled that the UK will stage its referendum on membership of the European Union in 2016 and made clear his view that continued membership is vital not just to economic security but to the fight against international terrorism.

His remarks, at the close of a two-day EU summit in Brussels, suggest that the prime minister knows he is not going to achieve all his negotiating demands and has decided to press ahead with the vote as soon as a final deal is struck at another summit in February.

The referendum is most likely to be staged in July as there are fears in No 10 that the migration crisis may have worsened by next autumn.

Cameron knows he has a party management problem now, with the possibility of high-profile cabinet resignations by those who are convinced the package does not change the fundamental contours of the UK relationship with Europe.

But he was buoyed by the reception he received at a dinner in Brussels on Thursday when, uniquely for a British prime minister, he was given 45 minutes to persuade the other 27 heads of government of the merits of his case for a new deal for Britain in Europe.

Senior EU policymakers taking part in the closed dinner described the outcome as a breakthrough, the first in six months of negotiations, and added that Cameron had gone a long way to winning his argument, paving the way for a detailed compromise deal by February.

But Cameron also faced strong resistance from his EU counterparts, particularly to his plans for changes to welfare rules for migrants.

The prime minister insisted that good progress had been made towards an agreement in February on reforms to the UK’s membership.

But three countries – Belgium, Portugal and Greece – staged a last-minute bid at midnight on Thursday to derail his campaign, demanding that the benefits curbs issue be dropped altogether from the negotiations.

They were overruled, but the incident highlighted European resistance to several of Cameron’s demands, problems certain to resurface over the next two months.

Cameron has promised to hold a public vote before the end of 2017, but a deal at the summit in February would clear the way for the referendum within six months. He is required to spend six weeks passing details of the legislation through parliament before four months are set aside for the campaign.

David Cameron's savvy speech to EU leaders offers hope of referendum win Read more

Speaking at a closing press conference designed to generate a sense of momentum, Cameron said: “We’ve made good progress. We are a step closer to agreement on the significant and far-reaching reforms I have proposed.

“It is going to be tough and there is a lot of hard work to do. But I believe 2016 will be the year we achieve something really vital, fundamentally changing the UK’s relationship with the EU and finally addressing the concerns of the British people about our membership.

“Then it will be for the British people to decide whether we remain or leave. It is a choice we will all need to think hard about.

“If we can get these reforms right – and I believe that we can – I firmly believe that for our economic security and increasingly for our national security, the best future for Britain is in a reformed European Union.”

He added: “If you think about the terrorist and security threats we face, and the situation brought about by what Russia has done in Ukraine, [and] the terrorist threat generated by the instability in the Middle East, I think we are better off standing together with our allies and partners in a reformed Europe and that is why, if anything, this negotiation has got more important.”

Several EU leaders listening to Cameron’s argument were highly impressed, triggering a mood change about the prospects of striking a deal that could keep Downing Street and the other countries satisfied.

There will now be intensive efforts after the new year holiday to find solutions that Cameron can package as a victory in the referendum campaign while not crossing “red lines” defined by the other Europeans and also reaching legal agreements in line with EU law.

Despite longstanding demands from No 10 that the EU’s Lisbon treaty would need to be renegotiated to meet Cameron’s terms, Enda Kenny, the Irish prime minister, said Cameron had emphasised to the other leaders that he was no longer seeking treaty change.

Asked if he had time to secure a deal by February, Cameron said: “I have been working on this with a clear mandate from the British people since May. What matters is that these changes are legally binding and irreversible.

“I want a deal in February. But I have set myself the deadline of the end of 2017 because I wanted to give myself time to get this right – it’s about the substance rather than the timing.”

He refused to go into further detail about the nature of the compromise on the issue of banning EU immigrants from receiving in-work benefits until they have been in the UK for four years.

But it is clear that he is looking at an alternative, such as an emergency brake that could be applied to these benefits if public services were under severe strain.

Cameron tried to broaden the scope of the welfare package to highlight three further elements. He knows that Iain Duncan Smith, the work and pensions secretary, is one of the cabinet ministers most likely to look at the welfare reforms with a forensic Eurosceptic view.

He said he was well on the way to ensuring that migrants would not have access to unemployment benefits for the first six months in the UK; anyone unable to secure a job after six months would have to leave; and EU migrants would not be allowed to send child benefit home.