CBS finally put a ring on it.

After months of discussions, CBS Corp., the network behind “The Big Bang Theory,” has agreed to tie the knot with Viacom to better position the two TV companies to compete against streaming video giants like Netflix and Disney.

The all-stock deal, announced Tuesday, unites CBS’s network shows as well as shows from its premium cable network Showtime with Viacom’s Nikelodeon and MTV, the makers of “SpongeBob SquarePants” and “Jersey Shore” respectively. It also reunites Sumner Redstone’s media empire for the first time since they split in 2006.

The new company will be called ViacomCBS and Redstone’s daughter, Shari Redstone, will be named chair. Shari Redstone — who heads National Amusements, the majority shareholders of both CBS and Viacom — has been pushing for the companies to reunite for years.

The companies’ boards agreed on an exchange ratio of 0.59625 CBS share for every Viacom Class B share, which means CBS’s current shareholders will own 61 percent of the combines company versus Viacom holders who get 39 percent.

The new ViacomCBS will have a market capitalization of $30 billion, but that still pales in comparison to competitors like Netflix, valued at $136 billion, and Walt Disney, valued at $245 billion.

It’s one reason Wall Street analysts and other media sources expect Shari Redstone to continue to hunt for acquisitions, including film studio Lionsgate or its premium cable network Starz. The board of CBS and Viacom have considered both entities before, sources said.

And as The Post previously reported, CBS has also considered acquiring Take-Two, the gaming company run by CBS interim chairman Strauss Zelnick, Sony Pictures and MGM. It has also mulled a potential merger with Discovery Communications, which owns the hit new reality show “90 Day Fiance” through its TLC network.

While another acquisition could come later, the CBS-Viacom deal has long been Shari Redstone’s top priority.

The two companies came close to merging a year ago but a rift over who would run the combined company derailed talks. At the time, Les Moonves was head of CBS. He has since left amid a series of sexual harassment complaints.

Viacom also nixed plans to merge with CBS in 2016.

Viacom’s current boss Bob Bakish has been named the combined company’s president and CEO. Joseph

Ianniello, CBS current acting CEO, will continue to run the CBS’ assets in his new role as chairman and CEO of CBS.

He took over the interim job last year after Moonves stepped down amid sexual misconduct allegations.