The freeholder boards in both counties approved the plan at meetings Wednesday night.
Gloucester will pay Cumberland County $2.5 million annually for every 100 inmates transferred. Gloucester County officials say they will save $10 million per year by the third year of the agreement.
Gloucester County expects to reduce the size of its jail staff, possibly by layoffs. Remaining Gloucester County guards will be in charge of transporting prisoners when the deal takes effect on July 1.
Corrections officers and some Cumberland County residents protested, saying a merger would raise safety concerns.