Oregon, Massachusetts and Maryland are exploring their legal options as they sever contracts with the creators of their troubled Obamacare websites.

Enrollments in the nation's healthcare program have nearly concluded, but for states whose insurance exchanges have been crippled by technical problems, a difficult phase is just beginning: potential legal battles and a race to overhaul their systems before federal grant money dries up.

Officials in Oregon, Massachusetts and Maryland are exploring legal options as they sever contracts with those who created their sites. All three states are considering a move to the federal exchange, which had its own grievous start-up problems but is now largely stable, or licensing the technology of a more successful state such as Connecticut.

In each case — and in Minnesota, where outside consultants said it could take two years to fix the state's website — the states have plowed remaining grant funds into tech surges to try to salvage their programs before Monday, the deadline for states that have not received extensions. IT teams were working in Maryland and Minnesota to help thousands of bewildered consumers whose applications were frozen or had vanished into what Minnesota Gov. Mark Dayton, a Democrat, called a "black hole."

In Oregon, where consumers still cannot enroll at the state exchange website, officials dispatched an army of workers and community allies to help panicked consumers — some with serious medical conditions and under threat of cancellation — enroll using paper applications. In Massachusetts, where the website failure threatened to increase the state's uninsured rate, officials have rushed to put more than 125,000 people on its Medicaid rolls to avoid a gap in their coverage.

But those rescues have been expensive, and contract disputes and painful decisions about whether to abandon $100-million projects will now play out just as Democrats are attempting to convince voters to embrace the law heading into the 2014 and 2016 elections. In addition to the legal entanglements, the federal Government Accountability Office plans to investigate what went wrong in Oregon and in other states, while the inspector general of Health and Human Services is looking into Maryland's difficulties.

David A. Friedman, who teaches business law and dispute resolution at Willamette University College of Law in Oregon, said the circumstances are aligned for lawsuits: "There are a lot of dollars on the table. There is reputation risk on the table for the companies that are involved. And there's probably a lot of opportunities for these companies to point the finger back at the people who employed them."

"Are you familiar with 'Bleak House'?" Friedman added, referring to the Charles Dickens novel about a never-ending lawsuit. "It could go on forever, and span entire terms of office for attorneys general."

The uneven performance of the independent exchanges in 14 states — which chose not to use the federal site, HealthCare.gov — has been among the biggest surprises of the Affordable Care Act. States including California, Washington and Kentucky have posted robust enrollment figures. But ironically, some of the biggest technical fiascoes have been in blue states where officials were most eager to expand coverage.

Like the federal government, a number of the underperforming states lacked a strong "systems integrator" who made sure all the pieces of the system worked together. State-to-state variance in performance has also exposed the "fundamental problems" with government technology contracting, said Sabrina Corlette, a professor at the Georgetown University Health Policy Institute's Center on Health Insurance Reforms.

"You have government employees, who are well-intentioned, good people but who don't understand software code, and basically have to trust that the vendors they hire know what they are doing," Corlette said. "There was such a gold rush on the part of these vendors that there was a lot of over-promising and underpricing."

Kevin Counihan, executive director of the much-praised Connecticut exchange, attributed his state's success to its effort to recruit outsiders who "were used to a lot of pressure, irrational time frames and a lack of resources," and were willing "to say no" when vendors offered complex features.

Nowhere have ambitious goals, technical limitations and a short time frame combined for a worse outcome than in Oregon, the only state where consumers still cannot enroll online. Although the state engaged in a herculean effort to enroll people through paper applications and its Medicaid fast track program, Gov. John Kitzhaber said during a recent news conference that he was angry and disappointed by the technical failures and that the state "retained all of our rights to pursue legal action." (The state has withheld payment of $25.6 million of the $69.5 million charged so far by its major vendor, Oracle America Inc.)