Cameron has vowed to hold such a referendum but the bill is aimed at forcing the Labour opposition to hold one too if they win the May 2015 general election.
Lawmakers in the 650-seat lower House of Commons voted 283 to zero in favour, with Conservatives trooping through to vote and many Labour and Liberal Democrat lawmakers staying away.
An identical bid failed in January. Having cleared the Commons, it got stuck in the upper house, the House of Lords, and ran out of time.
MP Bob Neill, who brought forward the bill Friday, said it was now time for opponents of an in-or-out vote to "put up or shut up".
He said Britain's relations with the EU needed legitimacy and consent and the bill was about giving voters a choice.
Foreign Secretary Philip Hammond, who backed the bill, told MPs: "This is surely the most important strategic question facing this country today -- the future of our relationship with the European Union."
"Europe today is very different from the Europe people voted for in 1975 and yet the British people have never been asked whether they agreed with any of these changes.
"So it should be no surprise to us that democratic support for the EU is fragile, to put it diplomatically."
If Cameron remains prime minister after the general election, he has pledged to attempt a renegotiation of Britain's relationship with the EU and then stage an in-or-out referendum on the outcome, by the end of 2017.
With the general election less than seven months away, both Conservative and Labour MPs are facing a stiff challenge to retain their seats from the populist UKIP, which favours an immediate withdrawal from the EU.
