Yahya moved to Málaga, and captured al-Qasim at Jerez de la Frontera, having him executed.
In 1025 he mustered another army to march on Córdoba where caliph Muhammad III, after news of the upcoming attack arrived, fled to Zaragoza.
He arrived on 9 November 1025; after a few days he left the government in the hands of his vizier Abu Ja`far Ahmad ben Musa while he returned to his secure stronghold of Málaga.
In June 1026 the people expelled Yahya's vizier and elected the last caliph, the Umayyad Hisham III.
After his definitive expulsion from Córdoba, Yahya created the independent taifa (kingdom) of Málaga, which he ruled until his death in 1035.