NEW YORK — Drugmakers and health insurers will gain millions of customers under legislation overhauling the U.S. medical system. The industry also will pay new fees to the government, and face stricter rules that may narrow profit margins and fuel mergers.

The bill that the House passed in a pair of votes Sunday expands coverage to 32 million uninsured Americans, according to congressional number crunchers. That means more sales for Pfizer, the world’s largest drugmaker; UnitedHealth Group, the largest health insurer; and a cluster of companies led by Amerigroup Corp. that specialize in managing services through Medicaid, a program that will grow in the remake.

The revamp will cost $940 billion over 10 years, with industry fees and taxes helping defray the cost of adding to the ranks of customers who can afford to pay their doctors, drugstores and hospitals. Because the legislation creates pressure to curb medical costs, companies may merge as a way to lower expenses, said Paul Keckley, executive director of the Deloitte Center for Health Solutions, a Washington-based research firm.

“You have some that are able to manage more efficiently and strategically and some that can’t,” Keckley said by telephone March 19. “You’ll see an acceleration of acquisitions.”

Drugmakers, who took part early in negotiations with the Senate Finance Committee and the White House, may have the most to gain. More health-care coverage “makes a difference in demand for drug products,” said John Sullivan, an analyst at Leerink Swann & Co. in Boston. People won’t have to skip doses of medicines as frequently to save money, he said.

And while the industry pays $28 billion in fees over nine years to help the elderly afford drugs, it avoided requirements to have complicated pricing agreements with the government in Medicare, the program for the elderly and disabled, said Ramsey Baghdadi, a researcher at the analysis firm Prevision Policy in Washington who specializes in pharmaceutical and biotechnology policy.

For health insurers, the potential increase in customers will be tempered by subsidy cuts for custom Medicare Advantage plans offered to the elderly, and the prospect of new regulations. The industry, through its trade group America’s Health Insurance Plans, argued as recently as March 18 that the legislation won’t control costs and that people will still wait until they’re sick to buy coverage.

Biotechnology companies, a group led by Amgen Inc., won 12 years of protection from generic medicines derived from proteins. The generics industry, led by Mylan Inc., based in Canonsburg, Pa., and Teva Pharmaceutical Industries Ltd., based in Petah Tikva, Israel, won a reprieve from a proposed ban on legal settlements in which the drugmakers are paid by brand-name manufacturers to delay introduction of the cheaper copies.

Hospitals, a group led by Community Health Systems Inc., of Franklin, Tenn., will have more paying customers and less bad debt as a result. Still, that won’t happen until 2014, Keckley said, meaning hospitals will look for mergers.

Makers of medical devices, Medtronic Inc. of Minneapolis among them, are likely to benefit the least, said Sullivan at Leerink Swann.

The industry will pay a 2.3 percent excise tax on certain devices starting in 2013, and may not gain the same revenue boost as pharmaceutical companies, insurers and hospitals, he said in a telephone interview March 19.

“The hospital industry is a winner,” Sullivan said. “The drug industry is probably a bit better off. The device industry could be a bit worse off. The biotech industry is relatively unscathed. And for managed care I think it’s a function of what happens with the individual mandate and how easy or hard it is to keep healthy people in the insurance pool.”

The 10-year legislation would set in motion the biggest change in health care since the 1965 creation of Medicare. Lawmakers voted 219-212 yesterday for the Senate version of health-care and 220-211 for a package of amendments that goes back to the Senate.

The legislation requires Americans to get insurance, offering government aid and new purchasing exchanges to help. Insurers such as Minnetonka, Minnesota-based UnitedHealth would get millions of new policyholders, while being required to accept all customers, even with pre-existing conditions.

Pfizer and smaller drugmakers will benefit because broader access to insurance means more people can afford to keep taking their medicines, Sullivan said.

The bill also closes a coverage gap in Medicare payments known as the “doughnut hole,” which caused some patients to skip doses of medicines or switch to generics from brand-name products to cut costs, said Baghdadi at Prevision Policy.

“The method of payment for closing the doughnut hole is a big win for pharma,” Baghdadi said in a March 18 research note. Drugmakers will pay about $3 billion a year for nine years to close the coverage gap rather than participate in a “rebate scheme on Medicare drugs,” he said. A rebate program exists in Medicaid, the state-federal program for the poor.

“The industry did not want to sign on to that type of approach again,” Baghdadi said. He said it may be easier for the industry to fight expansions of fees “than try to unwind a rebate program.”

Insurers may start to merge as well as they’re required to take on sicker patients in addition to healthy ones, Keckley at the Deloitte Center said.

To pay for the higher-cost patients with more medical needs, managed-care providers need large numbers of young, healthy people in their pool “to help spread the costs more effectively,” he said. For that reason, “consolidation in the insurance industry looks very inevitable,” he said.