LONDON — David Cameron, the British prime minister, has no one to blame but himself.

In 2013, besieged by the increasingly assertive anti-European Union wing of his own Conservative Party, Mr. Cameron made a promise intended to keep a short-term peace among the Tories before the 2015 general election: If re-elected, he would hold an in-or-out referendum on continued British membership in the bloc.

But what seemed then like a relatively low-risk ploy to deal with a short-term political problem has metastasized into an issue that could badly damage Britain’s economy, influence the country’s direction for generations — and determine Mr. Cameron’s political fate.

As the nation prepares to vote on Thursday, the betting markets are signaling that Britain will choose to remain in Europe, but polls suggest that the outcome is still too close to call.

On Tuesday, speaking in front of No. 10 Downing Street, Mr. Cameron warned that a decision to leave would be an “irreversible” choice. Appealing to older voters, many of whom tend to favor leaving Europe, Mr. Cameron urged them to think about what they would bequeath to the next generation.