The legendary story of how R. Moses came to Cordoba is found in Ibn Daud's book, The Book of Tradition. In it, we're told that R. Moses and his family were captured while on a trip to the west in order to raise money for the Sura Academy in Babylonia. His wife, fearing the worst, threw herself overboard. The rabbi and his son were eventually sold as slaves in Cordoba.
Once they were redeemed by the community, the great rabbi revealed the depth of his knowledge while innocently asking questions to Nathan, the head of the Academy in Cordoba. It is said that Nathan immediately yielded his authority to the stranger dressed in rags, and Hasdai, ever after, provided for R. Moses' well being. Under his direction, Spanish Jewry was no longer dependent on Babylonia for halachic decisions. He was succeeded by his son, Hanoch.
Sources: This material was originally published in Sparks! - an e-zine for Jewish families located on the Internet at http://www.sparksmag.com