David Cameron is making a “historic mistake” by adopting a defensive approach towards the EU which risks increasing the chances of a British exit, the outgoing European commission president José Manuel Barroso will warn on Monday.

In the strongest attack by Brussels on the Conservatives over their handling of the EU, Barroso will say that the prime minister’s plan to impose an “arbitrary cap” on immigrants from eastern Europe is contrary to EU law and will alienate Britain’s natural allies.

Barroso, the most anglophile commission president of the last 30 years, will give vent to deep frustration at British tactics when he takes the highly unusual step of venturing into internal UK affairs by warning that the Tories should learn from the Scottish referendum and not wait until the final days to make a positive case.

In a speech at Chatham House on Monday, Barroso will sweep aside his usual diplomatic language to say: “My experience is that you can never win a debate from the defensive. We saw in Scotland that you actually need to go out and make the positive case. In the same way, if you support continued membership of the EU you need to say what Europe stands for and why it is in the British interest to be part of it.

“And you need to start making that positive case well in advance, because if people read only negative and often false portrayals in their newspapers from Monday to Saturday, you cannot expect them to nail the European flag on their front door on Sunday just because the political establishment tells them it is the right thing to do.”

The intervention by Barroso, a month before he stands down after a decade as president of the commission, comes amid deep frustration among EU leaders about the way in which Cameron is hardening his approach to the EU in response to Ukip. Barroso was privately appalled when Philip Hammond, the foreign secretary who is meant to be drumming up support for Britain’s EU reform plans across Europe, told MPs on Friday that Tory plans for an in/out referendum amounted to “lighting a fire” under the EU.

The prime minister, who initially instructed his MPs to vote against an in/out referendum before changing his mind in 2012, is embarking on a fresh change of heart as he plans to impose restrictions on the free movement of citizens from EU member states. The prime minister had said the restrictions would be limited to cracking down on benefit tourism.

But the Sunday Times reported that Cameron is planning to cap the number of national insurance numbers issued to EU immigrants with low skills. This would hit the 11 eastern European states that have joined since 2004. National insurance numbers could be issued for a limited period to ensure the prime minister delivers on his pledge to reduce net migration to the tens of thousands.

Grant Shapps, the Tory chairman, told The World This Weekend on BBC Radio 4: “We cannot have an open-ended situation where people are able to always come to Britain in such a lop-sided arrangement.”

Barroso said that Cameron’s proposal would fall foul of EU law which guarantees the free movement of people. The Lisbon treaty of 2007 echoed the EEC’s founding 1957 treaty of Rome as it said “the free movement of persons is ensured”.

The commission president will say that the way in which the Tories have singled out the Poles, whose citizens have travelled to Britain in record numbers over the last decade, is self-defeating.

“It is an illusion to believe that space for dialogue can be created if the tone and substance of the arguments you put forward question the very principle at stake and offend fellow member states. It would be an historic mistake if on these issues Britain were to continue to alienate its natural allies in central and eastern Europe, when you were one of the strongest advocates for their accession.”

Barroso’s remarks are intended to highlight how Cameron is complicating the only route to achieve his goals – amending the Lisbon treaty which has to be approved by all 28 EU member states. He will draw a second parallel with the Scottish referendum as he reminds his audience that he said that Alex Salmond would have faced an immense challenge in negotiating EU membership.

“I created waves in February when asked about the possibility of regions leaving member states, as I pointed out that negotiating an accession treaty is no easy feat. Negotiating any major constitutional change is difficult and very risky. And the uncertainty it creates has a direct and immediate upstream impact on confidence, including the investment decisions of industry.”

Witold Sobków, the Polish ambassador to the UK, indicated that Warsaw would veto any proposal to amend the Lisbon treaty to limit free movement. Sobków told The World This Weekend: “We want the UK to remain in the EU so we will do our best to help the British government introduce some reforms in the functioning of the EU, enabling the UK to remain in the EU... [But] free movement of people is a fundamental freedom of the EU. So there are some things we can do and some things that we shouldn’t do.”

Nigel Farage said that Cameron was seeking to impose a limit on free movement because he is “terrified of Ukip”. The Ukip leader told the BBC: “I don’t often agree with Barroso. But what the prime minister is saying about limiting the number of EU migrants that come to Britain is simply untrue. He is doing it for political reasons because he is terrified of Ukip.”

Barroso will tease Farage by highlighting their contrasting tastes in alcohol to show how different nation states can work harmoniously in the EU. He will say: “For me the answer is a resolute no. I may prefer a glass or two of good red wine than a pint of beer when I am out on the election trail. But I too come from a country with a long history, a trading nation, proud of its culture and tradition. And it may be a revelation to some, but the vast majority of people living in Europe are also rather attached to their national identity – however they may choose to define it.”