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.
Pirlo eyes final repeat
"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.
Round-up: Salzburg look strong
Round-up: Rangers take lead