The use of foreign mercenaries was widespread in the medieval Mediterranean world and mercenary units were common in Muslim, Byzantine and Papal armies. Muslim armies, in particular, relied regularly on non-Muslim or recently Islamicized warriors such as Turks and sub-Saharan Africans. The existence of the farfanes is thus in no way exceptional. However, the actual origins of the farfan units remain undetermined. Three scenarios are usually mentioned by historians (which are not mutually exclusive).
The farfans may be considered to be a continuation of the complex network of alliances common in 10th-century Iberia. Muslim leaders commonly used units lent to them by their Christian allies or formed their own units with individuals exiled from Christian lands. These types of arrangements are well known due to the fame of El Cid, and as it was widespread in al-Andalus, it is possible that this habit was passed on to the other side of the Mediterranean in the 12th century.
According to another theory, the farfan units in North Africa were originally Christian slaves and prisoners of war held by the Almoravid dynasty after its successful offensives against the Christians in Iberia. Units composed entirely of slaves or recently-freed men were relatively common both in North Africa and in al-Andalus, so this theory of the origin of the farfan fits an observable pattern. The history of Reverter de La Guardia, a Catalan nobleman captured by the Almoravid army on a Spanish battlefield in the 1120s, is one of the earliest examples of a Christian mercenary fighting in North Africa and would support this scenario.
The third theory is related to the mass deportation of the Mozarab Christians from al-Andalus to North Africa in 1126 by the Almoravids. Once in the hostile Maghrebi environment, the Mozarabs would have had little choice but to seek the support of the Almoravid rulers and to enlist as soldiers in their armies. This alternative fits with the tribal designation of the farfans sometimes called Banu Farfan in the sources. The surname "Farfán de los Godos", may indicate a Gothic origin.