The Morocco international will move to Stamford Bridge from Ajax in the summer.
"I am looking forward to next season and hope we can achieve great things together."
Chelsea director Marina Granovskaia added: "We are delighted Hakim will be joining us in the summer, having been a key target of the club's in this last window.
"He has consistently been one of the most dangerous attacking players in Europe in recent years, which we saw first-hand in our two games against Ajax in the Champions League.
"We wish Hakim and Ajax all the best for the rest of the season and look forward to welcoming him to Stamford Bridge in the summer."