LONDON — Prime Minister David Cameron on Friday raised the prospect of Britain leaving the European Union unless fellow leaders agree to let him restrict access to welfare payments for immigrants.

In a speech in central England, Cameron demanded that Europeans arriving in Britain receive no welfare payments or state housing until they've been residents for four years. He said they should have a job offer before they get to Britain, shouldn't receive unemployment benefits and should be removed if they don't find work within six months.

It's the second time Cameron has been forced to make a speech in an attempt to counter the rise of the anti-E.U. Independence Party. In 2013, he promised a renegotiation of Britain's E.U. membership and then a referendum on leaving. With the Independence Party gaining ground and now holding two seats in Parliament, Cameron said that immigration, the focus of its campaigns will be a "key part" of that negotiation.

"If I succeed, I will, as I have said, campaign to keep this country in a reformed E.U.," he said. "If our concerns fall on deaf ears and we cannot put our relationship with the E.U. on a better footing, then of course I rule nothing out."

The speech reaffirmed Cameron's target for net immigration, first set out before the 2010 election, to reduce it to "tens of thousands" a year. That pledge, repeated in 2011, has undermined Cameron's credibility as the number of immigrants has risen.

Home Secretary Theresa May said this week the goal is "unlikely" to be met. Cameron described it Friday as an "ambition" and said the government would set out further, more detailed metrics, so people could see the origins of immigrants.

Newcomer numbers surge

Net migration to the United Kingdom surged 43 percent in the 12 months ending in June, with the number of long-term arrivals exceeding those leaving by 260,000, the Office for National Statistics said. Immigration from other E.U. nations was at a record high.

The failure to cut the number of newcomers has damaged Cameron's Conservative Party. Immigration overtook the economy this year as the most-mentioned subject in a poll of issues facing Britain.

"What we saw was a prime minister playing catch-up … and realizing he's out of touch," Independence Party leader Nigel Farage told BBC television. "The closer he comes to our position, the more justified people feel in voting for us."

The party argues that immigration can only be controlled by leaving the E.U. Cameron dismissed that argument.

"We should distrust those who sell the snake oil of simple solutions," he said. "There are no simple solutions. Managing immigration is hard. Those who say we would certainly be better off outside the E.U. only ever tell you part of the story."

The leader of the main opposition Labour Party, Ed Miliband, said that "Cameron has no credibility on immigration. People are not going to believe his new promises when he's broken his old promises."

Treaty changes needed

Answering questions after the speech, Cameron said his proposals will require E.U. treaty amendments. "There's some question about which bits of the treaty we need to change, but it will need some treaty change," he said.

In a first reaction from Poland, the country with the largest number of foreign nationals in Britain, Deputy Foreign Minister Rafal Trzaskowski said on Twitter that "there won't be any approval for limits on freedom of movement for workers, which is one of the E.U.'s pillars."

Cameron's coalition partner, Liberal Democrat Deputy Prime Minister Nick Clegg, said in televised remarks that "I doubt that all of the 27 other countries across the European Union are going to sign up to every dot and comma of David Cameron's blueprint." He said there are "serious practical question marks about some of the proposals."

Government policy on E.U. immigrants has so far focused on restricting welfare payments to those out of work. By including payments to those who have jobs, Cameron aims to give a competitive advantage to British citizens, who would be able to top up low pay with welfare payments, while immigrants working with them would not. He didn't mention options that had been floated in recent weeks, including a cap on numbers of immigrants or an "emergency brake" on immigration.

"I don't actually think that would be effective," he said when asked about those ideas. "There are countries in Europe with very high levels of immigration that don't want those sorts of controls."

Cameron stopped short of saying he would campaign to leave the E.U. if he didn't get his way. Instead, he appealed to fellow leaders, saying changing welfare rules was "absolutely key" to his negotiation.

Salim Rana, a Bangladesh-born Italian national who moved to London with his wife and children in May and works at a restaurant, said benefit limits would make it "more difficult" for immigrants.

"But I moved to England because schools and hospitals are better and the English language. For my children, English language is important. Not benefits," he said.