Ed Miliband was under renewed pressure on Friday night to harden Labour’s policy on immigration after the party’s perilously narrow win in the Heywood and Middleton byelection.

The slender 617-vote margin in a safe Labour seat revealed deep unease across the party that a Ukip surge could deprive it of a swath of northern marginal seats at next year’s general election.

Labour officials, urging calm in the face of the result as well as Ukip’s dramatic capture of its first seat from the Tories in Clacton, acknowledged Miliband would do more to highlight the party’s policies on immigration in the future.

Miliband admitted that disillusionment with Westminster politics, building for a long time, had led some traditional Labour communities to choose Ukip, adding in a direct message to Ukip supporters: “It is not prejudiced to worry about immigration.” But he said he would not make any false promises and resisted any immediate changes to a policy that he said had already been changed in 2010.

It was also suggested that conversations were being held with the former home secretary and union leader Alan Johnson to persuade him to take on a senior spokesman’s role in the election.

The Ukip leader, Nigel Farage, hailed the results, including the 12,000-vote win in Clacton over the Conservatives, and predicted the party might hold the balance of power in a hung parliament.

“The whole of British politics has been shaken up in a way that the complacent Westminster class could never even have contemplated,” he said.

“Something big is happening here. People want change. They have had enough of career politicians in three parties who don’t even understand the problems they face in their everyday lives.

“We’ve got a chance here in a general election next year that is likely to be very tight … we could find ourselves next May in a position where we hold the balance of power.”

David Cameron, who once described Ukip as mostly “a bunch of fruitcakes and loonies and closet racists” also acknowledged that Ukip might now deny him victory. “What last night demonstrates is that if you see a big Ukip vote, you will end up with Ed Miliband as prime minister and Ed Balls as chancellor,” he said. In an attempt to put a firebreak in the Ukip advance, the Tories are likely to move the writ for the Rochester and Strood byelection in Kent next week before choosing its candidates in a full postal ballot of constituents . The byelection, caused by the defection of the Tory MP Mark Reckless, is likely in early November.

The Labour former foreign secretary Jack Straw said it was crucial for Labour to show it was on people’s side on immigration. He said: “We were right to concentrate on the NHS. We’ve also, however, got to be stronger about our messages on immigration as well.”

John Mann, the Labour MP for Bassetlaw, directly urged Miliband “to announce that we’re prepared to renegotiate our role and position in the European Union and stop the automatic free flow of labour.

“People feel the speed of immigration is too fast and the price in terms of low pay and too much housing is too high,” he said.

One shadow cabinet member said “the free movement of labour is, as a phrase, a disaster, and we need to move to fair movement of labour at least as a language to describe our policies.”

Miliband and the shadow home secretary, Yvette Cooper, have each made three speeches setting out how they would extend qualification periods for EU immigrants to receive benefits, enforce the minimum wage and prevent the exploitation of cheap migrant labour.

Some senior party figures had wanted these messages highlighted alongside the NHS in the Heywood campaign, and would also now like Labour to raise openly in Europe questions about the long-term challenge posed by the free movement of unskilled labour across the EU. There has also been discussion about boosting the Home Office budget to strengthen its Border Force. The difficulty is that some of these reforms might require changes to European treaties, raising the prospect of Labour needing to support an in/out referendum on Britain’s EU membership.

The Labour MP Diane Abbott warned the party not to shift tack on immigration. “A helter-skelter rush to the right on race, immigration and welfare will not work. For one thing, if we choose to fight the next general election on a Ukip agenda, Labour will never be able to move far enough to the right on these issues to suit Ukip voters. And the danger is that, in trying to move right on immigration, we will alienate other voters.”

Douglas Alexander, the Labour election coordinator, appeared to resist a dramatic change in strategy, pointing out that the Labour share of the Heywood vote had risen, although the majority had fallen owing to the collapse in the vote of the coalition parties and a low turnout.

He said: “There is no instant magic policy, no speech or campaign tactic that can itself address the depth of disengagement we are seeing across the electorate. The coming months are not simply going to be a battle between Labour and the Conservatives. It’s going to be a battle against the sense of alienation and despair so many people feel about politics and how it’s been done in the past.”

The near defeat also led to wider warning for Labour to show more courage and run less bloodless campaigns. John McTernan, a normally loyal former adviser to Tony Blair, writing on the Progress website, warned: “We are in deep, deep trouble. We are lost and our voters want us back. They keep sending us messages. When will we listen?”