WASHINGTON — Two leading senators, hoping to stabilize teetering health insurance markets under the Affordable Care Act, reached a bipartisan deal on Tuesday to fund critical subsidies to insurers that President Trump moved just days ago to cut off.

At the White House, virtually as the deal was being announced, Mr. Trump voiced support for it while insisting that he would try again to repeal President Barack Obama’s signature health law.

The plan by the senators, Lamar Alexander, Republican of Tennessee, and Patty Murray, Democrat of Washington, would fund the subsidies for two years, a step that would provide at least short-term certainty to insurers. The subsidies, known as cost-sharing reduction payments, reimburse insurance companies for lowering deductibles, co-payments and other out-of-pocket costs for low-income customers.

Without them, insurance companies said, premiums for many customers purchasing plans under the Affordable Care Act would shoot up, and with profits squeezed, some of the companies would probably leave the market.

“In my view, this agreement avoids chaos,” Mr. Alexander said, “and I don’t know a Democrat or a Republican who benefits from chaos.”

Mr. Trump appeared to back the deal, even as he berated insurance companies, declared the Affordable Care Act “virtually dead” and promised the demise of the health law in due time.

“It’ll get us over this intermediate hump,” the president said at a Rose Garden news conference, describing it as “a short-term solution so that we don’t have this very dangerous little period.”

Passage of the deal negotiated by Mr. Alexander and Ms. Murray is still far from assured. If approved, the agreement could provide a reprieve for the Affordable Care Act that would prevent 2018 premiums from increasing as much as they might otherwise have gone up. But consumers in many states will still face double-digit rate increases, and in many counties, health plans will be available from only one insurance company.

Moreover, Mr. Trump and other Republicans are still intent on repealing much of the Affordable Care Act, and an executive order issued last week by Mr. Trump could destabilize markets in 2019 and later years by encouraging sales of health plans that skirt the coverage requirements of the health care law.

“For a period of one year, two years, we will have a very good solution,” Mr. Trump said. “But we’re going to have a great solution, ultimately, for health care.”

Mr. Alexander, the chairman of the Senate health committee, said that in addition to funding the payments to insurers, the deal would also give states “more flexibility in the variety of choices they can give to consumers” — a change that should appeal to Republicans eager to give states more say over health care.

“This takes care of the next two years,” Mr. Alexander said. “After that, we can have a full-fledged debate on where we go long-term on health care.”

The agreement bears the hallmarks of bipartisanship. For Republicans, state governments would find it easier to obtain waivers from certain requirements of the Affordable Care Act. But there would be explicit protections for low-income people and people with serious illnesses.

Consumers of any age would be allowed to obtain catastrophic insurance plans that typically have low monthly premiums but high deductibles and other out-of-pocket costs. Catastrophic plans provide protection against serious illnesses and injuries, but consumers must pay most routine medical expenses themselves.

Under current law, catastrophic plans are available only to people who are under the age of 30 or have received an exemption from the federal coverage requirement because they cannot afford other insurance.

For Democrats, not only would the cost-sharing reductions be brought back, but millions of dollars would be restored for advertising and outreach activities that publicize insurance options available in the health law’s open enrollment period, which starts next month. The Trump administration had slashed that funding.

“We will spend about twice as much or more than President Trump wanted to expend,” Mr. Alexander promised.

Senator Chuck Schumer of New York, the Democratic leader, hailed the agreement as a model for how the two parties could work together on other issues, such as taxes.

“I don’t expect the Republicans to give up their goal of repealing A.C.A.,” Mr. Schumer said. “But in the meantime, stabilizing the system, preventing chaos and stopping the sabotage is in everybody’s interest.”

The fate of the cost-sharing subsidies has been in doubt since a federal district judge ruled in 2016 that the payments to insurers were unconstitutional, because Congress had never appropriated money for them. Mr. Trump, whose administration has been taking steps to undermine operation of the health law, declared last week that he would stop the payments.

If the cost-sharing payments were cut off and premiums increased, many low-income people would receive more financial assistance, in the form of larger tax credits, to help pay the higher premiums. But many middle-income people who do not receive such assistance would have to bear the additional cost on their own.

A coalition of state attorneys general filed suit on Friday, and Congress immediately came under pressure to take action to ensure that the payments would continue. Doctors, hospitals and insurers, as well as the National Governors Association and the U.S. Chamber of Commerce, urged lawmakers to provide the funding.

Mr. Alexander said that he spoke with Mr. Trump over the weekend, and that the president encouraged his efforts with Ms. Murray, the top Democrat on the Senate health committee. But it remains to be seen whether conservative-leaning Republicans will get on board with the agreement, and whether the House will accept it.

It is not clear how the agreement might move through Congress. Supporters of funding the subsidies could push to have the deal included in a measure to keep the government open past Dec. 8. Democratic votes will be needed to fund the government, and the health care deal could come to fruition when Democratic leverage is particularly strong.

Some Republicans have already said they do not wish to provide what they describe as a bailout to insurers.

“I think it would be a mistake for Congress to provide billions in bailouts to insurance companies without providing meaningful relief to the millions of Americans who have been hurt by Obamacare,” Senator Ted Cruz of Texas said Tuesday before the deal was announced.

Mr. Alexander said the agreement would include “the strongest possible language” to guarantee that money provided for cost-sharing payments goes to the benefit of consumers, not insurance companies. “I want that, Senator Murray wants that, the president wants that,” he said.

The Senate majority leader, Mitch McConnell of Kentucky, gave no indication on Tuesday about when — or whether — the chamber might move ahead with the plan drawn up by Mr. Alexander and Ms. Murray.

Senator John Thune of South Dakota, a member of the Senate Republican leadership, said there would be “a sense of urgency to move a bill,” since Mr. Trump intended to stop the payments right away.

The House is away for a weeklong recess, and a spokesman for Speaker Paul D. Ryan of Wisconsin declined to comment.

A leading conservative in the House, Representative Mark Walker of North Carolina, the chairman of the Republican Study Committee, immediately declared the deal to be “unacceptable.”

“Obamacare is in a ‘death spiral,’ ” Mr. Walker said. “Anything propping it up is only saving what Republicans promised to dismantle.”

Another leading conservative, Representative Mark Meadows of North Carolina, the chairman of the hard-line House Freedom Caucus, described the agreement as a “good start,” but said “much more work needs to be done.”

“Most importantly,” he added, “it bears repeating: Republicans cannot allow short-term solutions to become a distraction to repealing and replacing Obamacare — something we’ve promised to do for seven years.”

Correction:

An earlier version of a picture caption with this article misstated the date on which Senators Patty Murray and Lamar Alexander were shown during a hearing of the Senate Committee on Health, Education, Labor and Pensions. The hearing was in September, not last week.

A version of this article appears in print on , on Page A1 of the New York edition with the headline: Deal by Senators Seeks to Restore Health Subsidies. Order Reprints | Today’s Paper | Subscribe