President Obama’s health-care legislation survived a close call at the Supreme Court. But the fight is far from over.

In state capitals, some governors are considering whether to opt out of one of the law’s most fundamental provisions: the expansion of Medicaid to cover 17 million of the poorest Americans.

And in Congress, Republicans still want to repeal the measure.

The two-year-old Affordable Care Act faces a slew of political and legal challenges from critics who want either to kill it or to alter the way it is implemented.

Arguably the most portentious question raised by the ruling is whether states will go along with the law’s expansion, beginning in 2014, of Medicaid to cover a larger share of the poor. The justices said the federal government can no longer punish a state that refuses to comply with the expansion by withholding funding from the state’s Medicaid program.

White House officials said they are confident that no states will back out.

Ronald Pollack, head of the advocacy group Families USA, which supports the law, also was optimistic. He argued that although the federal government may have lost a powerful stick, it still has a juicy carrot: hundreds of billions of dollars in federal aid.

For the first three years, he noted, the government will pay the entire cost of expanding Medicaid. As a result, from 2014 to 2019, the expansion will cause state spending on Medicaid to increase by only 1.4 percent, according to a study sponsored by the Kaiser Family Foundation. Even after the federal share is phased down, it will still amount to 90 percent.

“This is an incredible bargain that states are not going to want to refuse,” Pollack said.

Matt Salo, executive director of the National Association of Medicaid Directors, cautioned that cash-strapped state leaders may not see it that way.

Footing even just 10 percent of the bill for the expansion could prove daunting for states with the least-generous Medicaid programs. Texas, for example, covers only parents with incomes up to 26 percent of the federal poverty line, or about $2,900. To participate in the Medicaid expansion — which extends coverage to all individuals and families with incomes up to 133 percent of the federal poverty level — the state would have to spend $2.6 billion between 2014 and 2019, according to the Kaiser report.

State officials also worry that the federal match could go down over time, Salo said.

“There isn’t a state out there that isn’t fully aware that you’ve seen Congress and the White House talk about lowering Medicaid funding, and thinking that could go down,” he added.

A spokesperson for Texas Gov. Rick Perry (R), an opponent of the law, said the governor has not decided whether to proceed with the Medicaid expansion — a response echoed by leaders of other states that challenged the law.

The stakes are immense, said Joan Alker, co-executive director of the Center for Children and Families at Georgetown University. The Medicaid expansion is projected to help 17 million Americans gain insurance — nearly half of the estimated 34 million who will be newly covered under the law.

“The court’s decision on Medicaid means that the lowest-income parents and other adults could be the only Americans left behind, depending on where they live,” Alker said.

The decision could also pose a different challenge for Obama: the rising cost of the act’s implementation. If states opt out of the Medicaid expansion, it could either add to or reduce the federal deficit — it is unclear which.

Last year, it was estimated that the law would save $210 billion through 2021. But it absorbed a major financial blow last fall, when the Obama administration announced that it would not proceed with an initiative to provide Americans with insurance for long-term care. That program was expected to generate more in revenue in the early years than it paid out in benefits. Its demise could sharply increase the expected costs.

The nonpartisan Congressional Budget Office said Thursday that it will take some time to calculate the budgetary effect of the ruling.

The White House still faces a number of legal challenges from religious groups objecting to a requirement that most employers provide access to contraception for employees. Catholic bishops have called the mandate a major violation of religious liberty and have begun one of their biggest campaigns in a generation against it.

Then there is the political threat to the law: Republicans said Thursday that they will continue a push to repeal it outright.

“What the court did not do on its last day in session, I will do on my first day as president,” said Mitt Romney, the presumptive GOP nominee. If elected, Romney couldn’t repeal the law on his own. He would need help from Congress, including a Senate that is now in Democratic hands.

On Thursday, to show their resolve, the House’s GOP leaders announced that they will hold a vote on July 11 to repeal the law.

“The court makes a decision about whether this law is constitutional. Doesn’t mean that the law is wise. It doesn’t mean that the law is good for the country,” House Speaker John A. Boehner (Ohio) said in a news conference Thursday.

In the world of political theater, this would be something like a remake. The House previously voted to repeal the legislation in January 2011, just days after Republicans took over. But it died in the Senate, by a vote of 51 to 47.

On Thursday, many Democrats in Congress still felt safe to celebrate. House Minority Leader Nancy Pelosi (Calif.) called the widow of former senator Edward M. Kennedy (D-Mass.), a longtime advocate of health-care reform.

“Now Teddy can rest,” Pelosi told her, according to a Pelosi aide.

On Thursday, it wasn’t just activists and politicians asking themselves what happens next. Near Baltimore, Lashonda Edwards, 29, who has sickle-cell anemia, said her insurance does not cover visits to a specialist.

If the health-care law is fully implemented, she said, she may be able to find better insurance — or to be covered under and the expansion of Medicaid.

“I’m really excited,” she said. “It’s going to open up doors.”

Michelle Boorstein, Ed O’Keefe, Rosalind S. Helderman, Lori Montgomery and Sarah Kliff contributed to this report.