The Dutch attacker has been beset by injury problems since arriving at Camp Nou from PSV in December 2010 and has now moved to Greece in search of regular game time.
The injury-plagued Netherlands international has just one year left on his current contract with the Blaugrana and will spend it in Piraeus, the Catalan club announced Sunday.
MORE: Biggest summer transfers | Soccer's beautiful fans | WAGs
Afellay arrived at Camp Nou from PSV in December 2010 and enjoyed an encouraging start to life in La Liga, making 16 appearances in the second half of the season.
However, the attacker suffered an anterior cruciate ligament injury in September 2011 and his Barca career never recovered.
Indeed, Afellay featured only twice for the Blaugrana last season. Having been deemed surplus to requirements by new coach Luis Enrique, he has now been loaned to Olympiakos for the remaining 12 months of his contract.