In loan contracts there is a compulsory buy/sell contract that can be attached. I remember hearing about it on the European Football show.
Basically player goes on loan till x date, while agreeing terms with loaning team to officially join on y date. The player had to play in 15 games before the clause would go through