The NBA and its players have agreed to keep the most lucrative era in league history rolling.

The sides agreed Wednesday in principle on a new collective bargaining agreement, one that could last up to seven years and needs now only to be ratified by players and owners in the coming weeks. The deal was struck a day before the sides faced a deadline for opting out of the current deal.

If approved by votes of players and owners — likely to be formalities — there will be no lockout next summer and no labor issues for years to come.

“It’s amazing. I’m excited,” union president Chris Paul of the Los Angeles Clippers said. “I’m happy for our fans, the owners involved. It’s a great thing.”

Three people briefed on the terms said the deal extends for seven seasons, with an opt-out possible after six. The people spoke on condition of anonymity because neither side was releasing exact details.

If the deal is ratified, the season will start a week earlier, preseason games would be capped at six and one of the most dreaded elements of the schedule — the four-game-in-five-day stretches — may be eliminated.

Other details of the new proposed CBA include increases in values of rookie-scale contracts, minimum salaries and exceptions, with a 45 percent increase in minimum salaries across the board in the first year of the new agreement. The rookie deals will be proportionate to the salary cap, either rising or falling as that does. The average player salary is expected to hit $8.5 million next season and rise to $10 million by 2020-21 under the new terms.

“It’s fair. It’s fair,” said Miami Heat guard Wayne Ellington, his team’s player rep to the union. “That’s all we were asking for.”

The deadline for opting out has now been extended to Jan. 13, with the NBA saying that’s “in order to give both sides enough time to review the terms of the agreement and vote to ratify.”

“That’s the second-best news of the night,” Wizards coach Scott Brooks joked when asked about the CBA right after Washington’s victory over Charlotte.

Two-way contracts between the NBA and the D-League will be in play for the first time, which would figure to enhance player development. And contracts would be able to be extended for five, or in some cases, six years. That will give teams more leverage to keep homegrown players on their rosters, a priority for owners after Kevin Durant left Oklahoma City for Golden State this summer.