The US media giant Comcast has agreed to buy rival Time Warner Cable in a $45.2bn (£25.5bn) deal that unites the country's two biggest cable TV operators and will control more than a third of the market.

Comcast, which owns the NBC broadcast network and the Universal film studio, offered $158.82-a-share to take over Time Warner Cable (TWC), the cable firm spun off from media group Time Warner in 2009.

Brian Roberts, chairman and CEO of Comcast, said consumers would benefit from the "really special transaction", adding that he was "optimistic" that regulators would allow it. But consumer groups were aghast at the deal, saying it was "unthinkable" that it could be approved.

"This combination will drive us to have faster innovation in the highly competitive and dynamic market," Roberts said during a conference call. He said the deal was "pro-consumer", and added: "We have no business overlap, there's no competition."

Roberts said cable companies faced increasing competition from telecom companies like Verizon and Google, which is providing broadband and TV to a small but growing number of US cities via its Google Fiber division.

But critics immediately charged the deal would further reduce competition in an already heavily consolidated market. Craig Aaron, president of internet rights lobby group Free Press said: "In an already uncompetitive market with high prices that keep going up and up, a merger of the two biggest cable companies should be unthinkable. This deal would be a disaster for consumers and must be stopped.

"This deal would give Comcast control of more than a third of the US pay-TV market and more than half of the US triple-play market for video, voice and internet service. Comcast will have unprecedented market power over consumers and an unprecedented ability to exert its influence over any channels or businesses that want to reach Comcast's customers."

The surprise takeover comes after TWC rejected a $60bn offer from smaller rival Charter Communications as "grossly inadequate". Charter had been pursuing for eight months.

The proposed deal, which will create a company with about 30m customers, is expected to face intense regulatory investigation due to its dominance of the market.

Comcast has about 22m video subscribers and TWC has about 12m, with a significant presence in New York. The companies said they were prepared to divest 3m TWC subscribers to help win approval of the deal. The new company would tower over its closest video competitor, DirecTV, which has about 20m video customers.

AT&T was forced to abandon its $39bn merger with T-Mobile in 2011 after the Justice Department sued, arguing the combination of the country's second-and fourth-largest wireless carriers would violate antitrust law and "substantially lessen competition".

Roberts said he would not have proceeded with the deal had Comcast not been confident a deal would pass competition rules. Comcast is a major player in Washington. Chief lobbyist and executive vice president David Cohen is a major Democrat fundraiser and attended the state dinner honoring French President Francois Hollande this week. President Barack Obama has played golf with Roberts.

"The combination of Time Warner Cable and Comcast creates an exciting opportunity for our company, for our customers, and for our shareholders, Roberts said in a statement. "In addition to creating a world-class company, this is a compelling financial and strategic transaction for our shareholders. Also, it is our intention to expand our buyback program by an additional $10bn at the close of the transaction."

Robert Marcus, chairman and CEO of TWC, said: "This combination creates a company that delivers maximum value for our shareholders, enormous opportunities for our employees and a superior experience for our customers.

"Comcast and Time Warner Cable have been the leaders in all of the industry's most important innovations of the last 25 years and this merger will accelerate the pace of that innovation."

The new company will be led by Neil Smit, the current CEO and president of Comcast Cable Communications.

If successful, the deal will be the second time in little more than a year that Comcast has helped reshape the US media landscape after its $17bn acquisition of NBC Universal was completed in 2013.