LOS ANGELES -- Comcast will buy Time Warner Cable for about $45.2 billion in a deal that would combine the nation's top two cable TV companies and create a dominant force in creating and delivering entertainment.

The all-stock deal, which was approved by the boards of both companies, trumps a proposal from Charter Communications to buy Time Warner Cable for about $38 billion. It is expected to close by the end of the year, pending shareholder and regulatory approvals.

The combined entity will end up with about 30 million subscribers, as the two companies already have strongholds in major markets like New York, Chicago and Los Angeles. Comcast has 22 million pay TV customers but plans to divest 3 million after the deal closes. Time Warner Cable will contribute 11.2 million customers.