Magistrates at Bow Street Court, in London, said the "49s" game, run by Britain's biggest bookmakers, was a fixed-odds bet and not a lottery, and should, therefore, be allowed to continue.
The decision confirmed advice from the Crown Prosecution Service that the game did not contravene the 1976 Lotteries and Amusements Act.
But a spokeswoman for Camelot, Joanna Manning-Cooper, said the company was disappointed and intended to appeal. "This is just the first stage in the process of clarifying," she added.
The game was introduced in December last year by Ladbrokes, William Hill and Coral after all bookies reported severe losses because of competition from the National Lottery. Punters bet at fixed odds on whether up to five numbered balls will be among six chosen at random by a machine.
Camelot said it wanted to clarify whether a game very similar to the lottery should be allowed to draw the public - and therefore profits - away from the lottery and the good causes it funds.
But Ronald Bartle, stipendiary magistrate, said: "The predominant aspects of 49s are of betting and not a lottery."
He rejected Camelot's claims that legal costs should be met from the public purse. The company had claimed it was trying to clarify a legal principle.
Mr Bartle said: "I can't help coming to the view that this case was essentially about a commercial matter, fundamentally whether betting shops should be allowed to draw punters away from Camelot. I don't think that this type of action should be financed by the taxpayer."
Camelot had previously failed to persuade the Director of Public Prosecutions and the Attorney General to investigate the game. Customs & Excise and the Gaming Board had also advised that no public prosecution should be launched.
Mr Bartle ordered Camelot to pay the bookmakers' costs of pounds 305,000, as well as their own legal costs, which he indicated would match those of the bookmakers. He said his ruling on costs was influenced by Camelot's decision to bring a prosecution against expert advice.
Afterwards, John Brown, managing director of William Hill and chairman of 49s Ltd, said he was delighted: "49s has been of some help to the bookmaking industry in helping us to reduce the damage done to our business by the lottery."Reuse content