LOS ANGELES — In a move that will reverberate from Hollywood and Silicon Valley to TVs and smartphones around the world, the Walt Disney Company said Thursday that it had reached a deal to buy most of 21st Century Fox, the empire controlled by Rupert Murdoch, in an all-stock transaction valued at roughly $52.4 billion.

While the agreement is subject to the approval of antitrust regulators — and the Justice Department recently moved to block a big media company, AT&T, from becoming even bigger — Disney is acknowledging that the future of television and movie viewing is online. The acquisition, which would make Disney a colossus unlike anything Hollywood has ever seen, is the biggest counterattack from a traditional media company against the tech giants that have aggressively moved into the entertainment business.

Disney has already announced an ambitious plan to introduce two streaming services by 2019. With this deal and the wealth of movies, TV shows and sports programming it provides, the company will now have the muscle to challenge Netflix, Apple, Amazon, Google and Facebook in the fast-growing realm of online video.

“The pace of disruption has only hastened,” Robert A. Iger, Disney’s chief executive and chairman, said in an interview. “This will allow us to greatly accelerate our direct-to-consumer strategy, which is our highest priority.”