The 23-year-old former Danubio youngster had been at the Greek club since the age of 15 and rose to prominence last season playing for club and country.
He had been tipped to move to both Manchester City and Juventus but appears to have plumped for the cash of oil-rich Ukrainian runners-up Shakhtar.
"I agreed terms with Shakhtar, I do not want to say anything else right now," Castillo said.
Champions League
Pirlo eyes final repeat
06/08/2007 AT 14:10
"I thank the fans of Olympiacos who always supported me."
Shakhtar are meanwhile preparing to sell Brazilian attacking midfielder Elano to City in a £7.4 million deal. They have already sold compatriot Matuzalem to Real Zaragoza.
Champions League
Round-up: Salzburg look strong
01/08/2007 AT 21:22
Champions League
Round-up: Rangers take lead
31/07/2007 AT 21:12