Facebook, which has been renamed Meta, said it disagreed with the decision and is considering all its options, including an appeal.
"Both consumers and Giphy are better off with the support of our infrastructure, talent, and resources," the company said. "Together, Meta and Giphy would enhance Giphy's product for the millions of people, businesses, developers and API partners in the UK and around the world who use Giphy every day, providing more choices for everyone."
After consulting with other businesses and groups and assessing alternative solutions proposed by Facebook, the watchdog said it "concluded that its competition concerns can only be addressed by Facebook selling Giphy in its entirety to an approved buyer".
Stuart McIntosh, chairman of the watchdog's independent group that carried out the investigation, said the deal "has already removed a potential challenger in the display advertising market.
"Without action, it will also allow Facebook to increase its significant market power in social media even further, through controlling competitors' access to Giphy GIFs," he said.
"By requiring Facebook to sell Giphy, we are protecting millions of social media users and promoting competition and innovation in digital advertising."
New York-based Giphy's library of short looping videos, or GIFs, are a popular tool for internet users sending messages or posting on social media.
The two sides have waged a bitter battle over the deal, reportedly worth $400 million.
The Competition and Markets Authority said in a provisional decision in August that Facebook should be forced to sell Giphy. The social giant responded with a strongly worded letter, saying the provisional decision contained "fundamental errors".
Last month, the watchdog fined Facebook £50.5 million ($67.4 million) for failing to provide information needed for the investigation, saying the company's failure to comply was deliberate.
The watchdog has said that prior to the deal, Giphy had been considering expanding its advertising services to other countries, including the UK. That would have added a new player to the market and encouraged more innovation from social media sites and advertisers, but Facebook terminated Giphy's ad partnerships after announcing the deal, it said.
- AP