President Donald Trump is withdrawing a plan to ease the financial bite of costly medications for people on Medicare by letting them receive rebates that drugmakers now pay to insurers and middlemen, the White House said Thursday.

The once-highly promoted plan from Health and Human Services Secretary Alex Azar ran into opposition within the White House. The pushback grew after the nonpartisan Congressional Budget Office estimated the plan would have little impact on manufacturer prices and cost Medicare $177 billion over 10 years by leading to higher premiums subsidized by taxpayers.

White House spokesman Judd Deere said the proposal to create the rebate program was withdrawn "based on careful analysis and thorough consideration." It was not immediately clear whether that meant the end of the debate on rebates because other proposals on the same issue could surface on Capitol Hill, where lawmakers are working with the administration on drug cost legislation.

Deere said Trump is not backing away from his promise to lower drug prices, and the administration is setting its sights on bipartisan legislation in Congress . Various bills would cap drug copays for people with Medicare. Patients taking very expensive medications for cancer, rheumatoid arthritis and other conditions can now face copays that rival a mortgage payment.

"The Trump administration is encouraged by continuing bipartisan conversations about legislation to reduce outrageous drug costs imposed on the American people, and President Trump will consider using any and all tools to ensure that prescription drug costs will continue to decline," Deere said in a statement.

The administration's about-face was the second setback in a week for the president's drive to lower drug prices.

A federal judge in Washington, D.C., ruled on Monday that the administration did not have legal authority to require drugmakers to disclose list prices in their TV ads that were supposed to have started this week. But GOP Sen. Chuck Grassley, chairman of the Senate Finance Committee, and Illinois Sen. Dick Durbin, the chamber's second-ranking Democrat, are pushing legislation that would grant the government such powers.

Thursday's reversal on rebates appeared to be a win for insurers, employers, and middlemen called "pharmacy benefit managers" who administer prescription drug plans for large blocks of insured patients.

Shares of several big companies that manage prescription benefits started climbing early in the day. CVS Health Corp. and Cigna Corp. both jumped more than 7 percent, and UnitedHealth Group Inc. rose 4 percent while broader markets advanced slightly at the start of trading.

For the pharmaceutical industry, it looked like a defeat. Drugmakers preferred the consumer rebate approach to other ideas that lawmakers are considering. Those include "inflation rebates" that drugmakers would be pay directly to Medicare if they raise prices beyond a yet-to-be-determined measure.

"The administration has abandoned one of the only policy solutions that would have truly lowered what patients are forced to pay out of pocket for the medicines they need," Jim Greenwood, head of the Biotechnology Innovation Organization, said in a statement.

Labor Department data indicate that something different may be happening to drug prices.

Overall prescription drug inflation seems to have stabilized, with more monthly declines than increases recently. The White House credits Trump for that change, but independent experts say the trend isn't totally clear yet. The government's inflation index for medications also includes prices for lower-cost generics, and most consumers are worried about high-priced brand drugs.

Rebates are a largely unseen part of the complex world of drug pricing.

Under the administration's plan, drugmaker rebates now paid to insurance companies and their middlemen would have gone directly to seniors in Medicare's Part D program when they filled their prescriptions. But congressional analysts concluded that drug companies were unlikely to lower list prices across the board in response to the plan. Instead, they would reimburse pharmacies for discounts provided to individuals as they fill their prescriptions. Analysts also questioned how quickly and smoothly the program could have been rolled out.

Budget hawks within the administration saw their hand strengthened by the report.

The analysts did say that seniors who cannot afford their copays now would be clear winners. They would be better able to stay on their medications, and that could reduce Medicare hospital and outpatient spending by about $20 billion over 10 years.

But without insurers getting the rebates, the bottom line would have been an increase in premiums. Because the government subsidizes about 75% of the premium, that would add $170 billion to program spending from 2020-2029. Medicaid spending would also increase by $7 billion.

The administration's reversal was first reported by Axios.

FOLLOW NBC HEALTH ON TWITTER & FACEBOOK