So district officials want residents to gamble closer to home — inside their homes, actually. Or in cafes, restaurants and bars. By year’s end the district hopes to introduce an Internet gambling hub that would allow Washington residents to play blackjack, poker and other casino-style games.

“They can do it from Starbucks, a restaurant, bar or hotel, or from a private residence,” said Buddy Roogow, executive director of the D.C. Lottery, who expects the new games to eventually raise $9 million a year. “That’s real money in D.C.”

It’s an idea gaining currency around the country: virtual gambling as part of the antidote to local budget woes. The District of Columbia is the first to legalize it, while Iowa is studying it, and bills are pending in places like California and Massachusetts.

But the states may run into trouble with the Justice Department, which has been cracking down on all forms of Internet gambling. And their efforts have given rise to critics who say legalized online gambling will promote addictive wagering and lead to personal debt troubles.

The states say they will put safeguards in place to deal with the potential social ills. And they say they need the money from online play, which will supplement the taxes they already receive from gambling at horse tracks, poker houses and brick-and-mortar casinos.

“States had looked at this haphazardly and not very energetically until the Great Recession hit, but now they’re desperate for money,” said I. Nelson Rose, a professor at Whittier Law School, where he specializes in gambling issues.

When it comes to taxing gambling, he said, “the thing they have left is the Internet.”

Federal efforts over the last year to legalize online gambling have failed, so the moves by the District of Columbia and the states have put them into a murky legal arena with a potentially big obstacle. The Justice Department in recent years has vigorously pursued operators of offshore Internet casinos, shutting down their sites and arresting their executives when they travel to the United States.

The agency’s position has been that these operations violate federal laws including the Wire Act of 1961, which prohibits wagering over telecommunications systems that cross state or national borders.

The move by states to allow online wagering prompted two United States senators last month to ask the Justice Department to quash those efforts, too. In their letter, Senators Harry Reid, a Nevada Democrat, and Jon Kyl, Republican of Arizona, said that about a dozen states were considering such efforts.

“In many cases, Internet gambling advocates in those states cite the silence of the Department of Justice in the face of these efforts as acquiescence,” the letter says. “We respectfully request that you reiterate the Department’s longstanding position that federal law prohibits gambling over the Internet, including intrastate gambling (e.g. lotteries).”

Alisa Finelli, a spokeswoman for the Justice Department, declined to comment beyond saying that the department was considering the senators’ letter.

In the past, federal prosecutors have sent letters to a handful of states telling them that federal law prohibits “all forms” of online gambling. And in 2006, Congress passed the Unlawful Internet Gaming Enforcement Act, which prohibits businesses from taking the proceeds of illegal bets placed over the Internet.

But legal experts say the law sent a mixed message to the states. It seems to carve out an explicit exception for states to run online gambling operations. But in the bill’s legislative history, it says it is not meant to amend existing law on the subject, which can be taken to mean that the Wire Act prohibitions still apply, said Mark Hichar, a lawyer who specializes in gambling law at Edwards, Angell, Palmer & Dodge in Boston.

“The legislative history is a real head-scratcher,” Mr. Hichar said.

Arthur Terzakis, staff director of the Committee on Governmental Organization, a legislative policy committee in the California State Senate, said the 2006 law “gives states the right to do this.”

Two California state senators late last year introduced bills to allow Internet gambling inside the state, estimating that such a move could raise roughly $1.4 billion to $2 billion over 10 years. One bill legalizes only online poker, while the other allows an array of games of chance and skill. The bills are still pending. California and other states say they will require proof of residency or use technological means to screen out nonresidents.

Some states, including New York and North Dakota, already sell lottery subscriptions online. Since 2005, New York has offered a subscription service that allows people in the state to enter a string of Lotto or Mega Millions drawings. The state says 100,000 people subscribe.

New York is exploring whether to allow people to draw from an escrow account when they decide to buy into a single drawing — say, when the jackpot reaches alluring levels.

The lack of a challenge against existing online lotteries from the Justice Department has given hope to other states that they will have clear legal sailing. But Mr. Hichar, the gambling lawyer, said the existing efforts may just “have flown below the radar.”

Illinois, which passed a law two years ago allowing it to put its lottery online, asked the Justice Department about its plan but has not heard one way or another, suggesting it can move ahead, said John Cullerton, president of the State Senate.

He said Illinois had budgeted to gain some $200 million in additional revenue from moving the lottery online and allowing people to buy into it who “don’t want to wait in line at a 7-Eleven.”

“We’ll be selling to new players, not the same old players,” he said. “That means more roads and bridges.”

Officials in other states sympathize with the logic.

“We need money,” said Matt Fitzgerald, legislative director for Michael Rush, a Massachusetts state senator, who last month introduced a bill to allow the state lottery to test an expansion into other “games of chance,” but not poker.

It’s not all about revenue. In Iowa, which is running a budget surplus, lawmakers say they want to legalize online poker to create a regulated forum for a popular activity.

“A number of Iowans are doing it and may not even realize it’s illegal,” said Jeff Danielson, a Democrat and the president pro tempore of the State Senate. “We want a regulated environment that’s safe and protects consumers.”

Earlier this year, a bill to make New Jersey the first state to legalize online gambling passed the Legislature, but Gov. Chris Christie vetoed it.

Some critics say the state efforts will make gambling too accessible.

“It’s the equivalent of opening a lottery retailer in every home, office and dorm room in America,” said Les Bernal, executive director of the Stop Predatory Gambling Foundation, a nonprofit advocacy group.

“It’s a business model built on addiction and indebtedness,” he said.