Facebook's parent company, Meta, has been ordered to sell Giphy by the UK's Competition and Markets Authority.
The company, then known simply as Facebook, bought the Gif-sharing search engine last year for a reported $315m (£236m).
It planned to integrate Giphy's vast database of looping short video animations with another of its existing social-media platforms, Instagram.
But the CMA ruled the purchase unfair to competing social-media platforms.
Facebook adopted Meta as its new corporate name, in October - but individual platforms owned by the company, Facebook, Instagram and WhatsApp, retain their original identities.
In May 2020, when it announced its acquisition of Giphy, it said 50% of the Gif search engine's traffic already came from Facebook platforms - half of that from Instagram.
But Giphy also provides Gifs to competitors such as TikTok, Snapchat and Twitter.
Gif stands for Graphics Interchange Format, an image format developed in the 1980s to display static and moving images.
And they have become a staple of social-media posts and comments.
The CMA said: "After consulting with interested businesses and organisations - and assessing alternative solutions put forward by Facebook - the CMA has concluded that its competition concerns can only be addressed by Facebook selling Giphy in its entirety to an approved buyer."
Stuart McIntosh, who chaired the independent inquiry into the acquisition, said without action it would "allow Facebook to increase its significant market power in social media even further, through controlling competitors' access to Giphy Gifs".
"By requiring Facebook to sell Giphy, we are protecting millions of social-media users and promoting competition and innovation in digital advertising," he added.
Experts said the decision by the regulator was a significant one.
Peter Broadhurst, partner at law firm Crowell & Moring, said: "This is the first time the CMA has ever blocked a major digital tech deal and indicates the direction of travel for the UK regulator's oversight of similar deals going forward."
In its decision the CMA noted that Giphy's advertising services had the "potential" to compete with Facebook's.
"This will cause quite a lot of uncertainty for companies trying to do deals where the parties don't actually compete but maybe could do in the future - particularly where one of them may be big in its own market," said Mr Broadhurst.
But Meta told BBC News: "We disagree with this decision.
"We are reviewing the decision and considering all options, including appeal.
"Both consumers and Giphy are better off with the support of our infrastructure, talent, and resources.
"Together, Meta and Giphy would enhance Giphy's product for the millions of people, businesses, developers and API [application programming interface] partners in the UK and around the world who use Giphy every day, providing more choices for everyone."
In June 2020, the CMA sent an enforcement order to Facebook, effectively putting a hold on any merging of the companies until its investigation was over.
In August 2021, it announced its provisional findings - the acquisition would "harm competition between social-media platforms and remove a potential challenger in the display-advertising market".
At the time, the CMA warned "it could require Facebook to unwind the deal and sell off Giphy in its entirety".
But Meta's lawyers said this provisional finding contained "fundamental errors of law and fact".
By seeking to undo the acquisition "in circumstances where Giphy does not even carry on business in the UK, not only is the CMA engaging in extraterritorial overreach but the CMA is sending a chilling message to start-up entrepreneurs, 'Do not build new companies because you will not be able to sell them,'" they said.