Governments will pay nearly half the healthcare bills in the U.S. in the next decade, according to a new study examining the impact of an aging population.

About 19 million baby boomers will join the Medicare ranks over the next decade or so, leading to higher spending by the federal insurance program for seniors, according to the study.

The Office of the Actuary for the Centers for Medicare and Medicaid Services on Tuesday released its annual healthcare spending projections from 2014 to 2024. It offered a detailed look at the impact of baby boomers on Medicaid — which offers nursing home and home care coverage for seniors — and Medicare.

A projected four of every 10 healthcare dollars will be spent on Medicare and Medicaid enrollees from 2016 to 2024, according to the study. As a result, state, federal and local governments are expected to cover nearly half of all U.S. health expenses, the study said.

In addition, the share of national health spending paid for by Medicare is projected to rise from about 20 percent in 2013 to 22.5 percent in 2024, the study said. That is mainly due to more baby boomers enrolling.

Medicare spending is expected to average nearly 8 percent over current spending levels from 2019 to 2024, according to the study. That reflects more baby boomers entering the program and older beneficiaries using healthcare at higher rates, according to the study.

Spending growth for each Medicare beneficiary will be nearly 5 percent from 2019 to 2024, compared with nearly 3 percent in 2013, according to the study published in the journal Health Affairs.

The baby boomer surge isn't expected to just affect Medicare. It also will lead to a nearly 6 percent growth from 2019 to 2024 for Medicaid, the federal program for low-income residents, which is already grappling with the additional recipients from the Obamacare expansion.

There is hope, though, that healthcare costs could lessen for Medicare beneficiaries.

A study published Tuesday found that mortality rates, hospitalization rates and costs for Medicare patients fell from 1999 to 2013. The study of about 68 million Medicare beneficiaries found that the hospitalization cost for each beneficiary declined from $3,290 to $2,801.

For the last six months of life, total hospitalizations and patient costs also decreased in recent years, according to the study published in the Journal of the American Medical Association.