Ancestry of Spanish and Portuguese people
The ancestry of modern Iberians (comprising the Spanish and Portuguese) is consistent with the geographical situation of the Iberian Peninsula in the South-west corner of Europe, showing characteristics that are largely typical in Southern and Western Europeans. As is the case for most of the rest of Southern Europe, the principal ancestral origin of modern Iberians are Early European Farmers who arrived during the Neolithic. The large predominance of Y-Chromosome Haplogroup R1b, common throughout Western Europe, is also testimony to a sizeable input from various waves of (predominantly male) Western Steppe Herders that originated in the Pontic-Caspian Steppe during the Bronze Age. 
Modern Iberians' genetic inheritance largely derives from the pre-Roman inhabitants of the Iberian Peninsula who were deeply Romanized after the conquest of the region by the ancient Romans:
There are also some genetic influences from the Alans and Germanic tribes who arrived after the Roman period, including the Suebi, Hasdingi Vandals, and Visigoths. Due to its position on the Mediterranean Sea, like other Southern European countries, there were also contacts with other Mediterranean peoples such as the Phoenicians, Ancient Greeks and Carthaginians who briefly settled along Iberia's eastern and southern coasts, the Sephardi Jewish community, and Berbers and Arabs arrived during Al-Andalus, all of them leaving some North African and Middle Eastern genetic influences, particularly in the south and west of the Iberian Peninsula. Similar to Sardinia, Iberia was slightly less impacted from the Hellenistic Eastern Mediterranean migrations by its western and southern geographic location, and thus has both lower levels of Eastern Mediterranean and higher ones of African admixture than Italy and Greece, most of which probably arrived to Iberia during historic rather than prehistoric times, especially in the Roman period. Nevertheless over half of both Iberian and Sardinian Iron Age genetic profiles were replaced during the centuries long Punic, Roman Imperial and Islamic dominations, with only the Basques remaining largely unaffected.
Population Genetics: Methods and Limitations.
The foremost pioneer of the study of population genetics was Luigi Luca Cavalli-Sforza. Cavalli-Sforza used "classical genetic markers" to analyse DNA by proxy. This method studies differences in the frequencies of particular allelic traits, namely polymorphisms from proteins found within human blood (such as the ABO blood groups, Rhesus blood antigens, HLA loci, immunoglobulins, G-6-P-D isoenzymes, among others). Subsequently, his team calculated genetic distances between populations, based on the principle that two populations that share similar frequencies of a trait are more closely related than populations that have more divergent frequencies of the trait.
Since then, population genetics has progressed significantly and studies using "direct DNA analysis" are now abundant and may use mitochondrial DNA (mtDNA), the non-recombining portion of the Y chromosome (NRY) or autosomal DNA. MtDNA and NRY DNA share some similar features which have made them particularly useful in genetic anthropology. These properties include the direct, unaltered inheritance of mtDNA and NRY DNA from mother to offspring and father to son, respectively, without the 'scrambling' effects of genetic recombination. We also presume that these genetic loci are not affected by natural selection and that the major process responsible for changes in base pairs has been mutation (which can be calculated).
Whereas Y-DNA and mtDNA haplogroups represent but a small component of a person's DNA pool, autosomal DNA has the advantage of containing hundreds and thousands of examinable genetic loci, thus giving a more complete picture of genetic composition. Descent relationships can only to be determined on a statistical basis, because autosomal DNA undergoes recombination. A single chromosome can record a history for each gene. Autosomal studies are much more reliable for showing the relationships between existing populations but do not offer the possibilities for unraveling their histories in the same way as mtDNA and NRY DNA studies promise, despite their many complications.
Analyses of nuclear and ancient DNA.
Nuclear DNA analysis shows that Spanish and Portuguese populations are most closely related to other populations of western Europe.
There is an axis of significant genetic differentiation along the east–west direction, in contrast to remarkable genetic similarity in the north–south direction. North African admixture, associated with the Islamic conquest, can be dated to the period between c. AD 860–1120.
A study published in 2019 using samples of 271 Iberians spanning prehistoric and historic times proposes the following inflexion points in Iberian genomic history:
North African influence.
A number of studies have focused on ascertaining the genetic impact of historical North African population movements into Iberia on the genetic composition of modern Spanish and Portuguese populations. Initial studies pointed to the Straits of Gibraltar acting more as a genetic barrier than a bridge during prehistorical times, while other studies point to a higher level of recent North African admixture among Iberians than among other European populations, albeit this is as a result of more recent migratory movements, particularly the Moorish invasion of Iberia in the 8th century.
In terms of autosomal DNA, the most recent study regarding African admixture in Iberian populations was conducted in April 2013 by Botigué et al. using genome-wide SNP data for over 2000 European, Maghreb, Qatar and Sub-Saharan individuals of which 119 were Spaniards and 117 Portuguese, concluding that Spain and Portugal hold significant levels of North African ancestry. Estimates of shared ancestry averaged from 4% in some places to 12% in the general population; the populations of the Canary Islands yielded from 0% to 96% of shared ancestry with north Africans, although the Canary islands are a Spanish exclave located in the African continent, and thus this output is not representative of the Iberian population; these same results did not exceed 2% in other western or southern European populations. Sub-Saharan African ancestry was detected at less than 1% in Europe, with the exception of the Canary Islands. However, contrary to past autosomal studies and to what is inferred from Y-Chromosome and Mitochondrial Haplotype frequencies (see below), it does not detect significant levels of Sub-Saharan ancestry in any European population outside the Canary Islands. Indeed, a prior 2011 autosomal study by Moorjani et al. found Sub-Saharan ancestry in many parts of southern Europe at ranges of between 1-3%, "the highest proportion of African ancestry in Europe is in Iberia (Portugal 4.2±0.3% and Spain 1.4±0.3%), consistent with inferences based on mitochondrial DNA and Y chromosomes and the observation by Auton et al. that within Europe, the Southwestern Europeans have the highest haplotype-sharing with North Africans."
Recent studies show minor relationships between some Iberian regions and North African populations as a result of the Al-Andalus historical period which in Portugal lasted between the 8th and 12th centuries AD, and in southern Spain continued until the late 15th century AD. Iberia is the European region that has a more prominent presence of haplogroup E3b of the human Y chromosome (E-M81), of haplogroup U (U6) and Haplotype Va, and this may be the result of some original common western Mediterranean population. In Portugal, North African Y-chromosome haplogroups (especially those typically North-West African) are at a frequency of 7.1%. Some studies of mitochondrial DNA also find evidence of the North African haplogroup U6, especially in northern Portugal. Although the frequency of U6 is low (4–6%), it was estimated that approximately 27% of the population of northern Portugal had some North African ancestry, as U6 is also not a common lineage in North Africa.
According to some studies, the North African and Arab elements in the ancestry of today's Iberians are more than trivial when compared to the basis of pre-Islamic ancestry, and the Strait of Gibraltar seems to function more as a genetic bridge than a barrier. 
However, a study that has used different genetic markers has reached different conclusions. In an autosomal study by Spínola et al. (2005), which analyzed the human leukocyte antigen (HLA genes) (inherent in all ancestors in direct paternal and maternal lineages) in hundreds of individuals from Portugal, showed that the Portuguese population has been influenced by other Europeans and North Africans, via many ancient migrations. According to the authors, the North and the South of Portugal show a greater similarity towards North Africans as opposed to the people of the center of the country, who seem closer to other Europeans, since the North of Portugal seems to have concentrated, certainly due to the pressure of Arab expansion, an ancient genetic pole originating from many North Africans and other Europeans, influences through millennia, while southern Portugal shows a North African genetic influence, probably the result of origins recent from the Amazigh people who accompanied the Arab expansion.
According to a study published in the American Journal of Human Genetics in December 2008, 30% of modern Portuguese (23.6% in the north and 36.3% in the south) have DNA that shows they have male Sephardic Jewish ancestry and 14% (11.8 in the North and 16.1% in the South) have Moorish ancestry. Despite the possible alternative sources for lineages attributed to a Sephardic Jewish origin, these proportions were testimony to the importance of religious conversion (voluntary or forced), shown by historical episodes of social and religious intolerance.
In terms of paternal Y-Chromosome DNA, recent studies coincide in that Iberia has the greatest presence of the typically Northwest African Y-chromosome haplotype marker E-M81 in Europe, with an average of 3%. as well as Haplotype Va. Estimates of Y-Chromosome ancestry vary, with a 2008 study published in the American Journal of Human Genetics using 1140 samples from throughout the Iberian peninsula, giving a proportion of 10.6% North African ancestry to the paternal composite of Iberians. A similar 2009 study of Y-chromosome with 659 samples from Southern Portugal, 680 from Northern Spain, 37 samples from Andalusia, 915 samples from mainland Italy, and 93 samples from Sicily found significantly higher levels of North African male ancestry in Portugal, Spain and Sicily (7.1%, 7.7% and 7.5% respectively) than in peninsular Italy (1.7%).
Other studies of the Iberian gene-pool have estimated significantly lower levels of North African Ancestry. According to Bosch et al. 2000 "NW African populations may have contributed 7% of Iberian Y chromosomes". A wide-ranging study by Cruciani et al. 2007, using 6,501 unrelated Y-chromosome samples from 81 populations found that: "Considering both these E-M78 sub-haplogroups (E-V12, E-V22, E-V65) and the E-M81 haplogroup, the contribution of northern African lineages to the entire male gene pool of Iberia (barring Pasiegos), continental Italy and Sicily can be estimated as 5.6 percent, 3.6 percent and 6.6 percent, respectively". A 2007 study estimated the contribution of northern African lineages to the entire male gene pool of Iberia as 5.6%." In general aspects, according to (Bosch et al. 2007) "...the origins of the Iberian Y-chromosome pool may be summarized as follows: 5% recent NW African, 78% Upper Paleolithic and later local derivatives (group IX), and 10% Neolithic" (H58, H71).
Mitochondrial DNA studies of 2003, coincide in that the Iberian Peninsula holds higher levels of typically North African Haplotype U6, as well as higher frequencies of Sub-Saharan African Haplogroup L in Portugal. High frequencies are largely concentrated in the south and southwest of the Iberian peninsula, therefore overall frequency is higher in Portugal (7.8%) than in Spain (1.9%) with a mean frequency for the entire peninsula of 3.8%. There is considerable geographic divergence across the peninsula with high frequencies observed for Western Andalusia (14.6%) and Córdoba (8.3%)., Southern Portugal (10.7%), South West Castile (8%). Adams et al. and other previous publications, propose that the Moorish occupation left a minor Jewish, Saqaliba and some Arab-Berber genetic influence mainly in southern regions of Iberia.
The most recent and comprehensive genomic studies establish that North African genetic ancestry can be identified throughout most of the Iberian Peninsula, ranging from 0% to 12%, but is highest in the south and west, while being absent or almost absent in the Basque Country and northeast. Hernandez et al. (2020) identified 11.17 ± 1.87% North African ancestry in southern Portuguese samples (from a population similar to modern northern Moroccans and Algerians), 9.28 ± 1.79% of such ancestry in western Andalusians, and an average of 1.41 ± 0.72% sub-Saharan ancestry in southern Iberians (using Yoruba as a proxy source). Lazarids et al. (2014) detected 12.6 ± 2% North African ancestry and an average of 1.5 ± 0.2% sub-Saharan ancestry in the Spanish population.
Current debates revolve around whether U6 presence is due to Islamic expansion into the Iberian peninsula or prior population movements and whether Haplogroup L is linked to the slave trade or prior population movements linked to Islamic expansion. A majority of Haplogroup L lineages in Iberia