LONDON — He was accused of hypocrisy, scaremongering and a failing common among politicians worldwide — waffling.

Yet Prime Minister David Cameron kept his cool under pressure on Thursday as he appealed to Britons to remain in the European Union during the first major television forum before the country’s referendum on whether to stay.

During the hourlong broadcast on Sky News, Mr. Cameron was pressed repeatedly by an interviewer over the high levels of immigration into Britain. After that came a combative town-hall-style session with an audience of voters.

And while it might not prove a decisive moment for the June 23 referendum, the debate could energize a campaign that has shown relatively few signs of igniting public interest.

During the broadcast, Mr. Cameron pointed out the economic risks of quitting the European Union, arguing that leaving its single market of about 500 million people would be an “act of self-harm,” and appealing to voters not to “roll a dice” on the economic futures of their children and grandchildren.

A succession of institutions including the International Monetary Fund, the Organization for Economic Cooperation and Development, and the Bank of England have echoed Mr. Cameron’s warnings of the likely adverse economic consequences of a withdrawal, known as Brexit.

But from the start of his interview on Sky News, Mr. Cameron was pressed by its political editor, Faisal Islam, on the issue of immigration and on his government’s failure to keep its pledge to restrict the number of arrivals to below 100,000 people a year.

Migration has emerged as the strongest issue for those campaigning for Britain to quit the European Union. They argue that Britain will never be able to control immigration as a member of the union because citizens of countries inside the bloc can live and work in other member nations, and Britain, with its relatively successful economy, has attracted many workers from the east and south of Europe.

Mr. Islam got a laugh from the studio audience when he parodied some of the claims about the consequences of a Brexit, which critics believe are exaggerated. “What comes first: World War III or the global Brexit recession?” he asked.

But perhaps the most memorable comment of the evening came from a member of the audience, Soraya Bouazzaoui, who, when dissatisfied with a response from Mr. Cameron interjected, “I’m an English literature student; I know waffling when I see it.”

Mr. Cameron responded calmly, insisting that claims from his opponents that millions of Turkish citizens would soon be able to live in Britain were fanciful.

Turkey is not likely to join the European Union soon, Mr. Cameron said, pointing out that talks on its membership had stalled and that Britain and every other member nation could veto its entry.

Mr. Cameron also defended himself from accusations of “hypocrisy and scaremongering” for campaigning alongside the new London mayor, Sadiq Khan, of the opposition Labour Party. During the mayoral election campaign, Mr. Cameron repeated accusations that Mr. Khan had spoken at events where people with ties to Islamist extremists also spoke.

Mr. Cameron’s governing Conservative Party is deeply split over the referendum, and the format of pre-referendum television debates has proved controversial.

Hoping to limit damage to his party, Mr. Cameron is avoiding a head-to-head confrontation with members of his cabinet who support a British withdrawal. So, the justice secretary, Michael Gove, will make the case for Brexit on Friday in a separate program.

With the Conservative Party divided, a pivotal factor in the referendum outcome will be the willingness of those who normally vote for the Labour Party to turn out and cast their ballots to remain in the union, their party’s official position.

The Labour leader, Jeremy Corbyn, has been accused of being halfhearted in his support for European Union membership. But on Thursday he called again for a vote to remain, and argued that the bloc had helped to lift environmental standards and to protect workers’ rights.

In a speech in London, Mr. Corbyn also defended immigration, arguing that Britain “cannot and should not want to close the borders.” Many non-British Europeans help sustain the British health service, he said, and many Britons exercise their reciprocal rights to work in other nations on Europe’s mainland.

The main group campaigning for a withdrawal, Vote Leave, faced an unexpected setback on Thursday when it had to evacuate its London headquarters as water gushed in from a floor above. Paul Stephenson, a spokesman for the group, joked that there was no indication that the episode was an act of pro-European sabotage.