To study the diet of the swordfish (Xiphias gladius) in the Strait of Gibraltar, a total of 176 stomachs were examined from the Moroccan artisanal fishery targeting this species, from April to September 2015. The frequency of occurrence (FO), percentage in number and in weight of prey as well as the per cent index of relative importance of prey (%IRI) were calculated to assess the diet preferences of swordfish in relation to its body size, sex and month. Our findings confirm the opportunistic feeding behaviour of swordfish. The prey items consist primarily of fish (54.6% in number and 82.7% in weight), followed by cephalopod (43.36% in number and 17.25% in weight). The Atlantic horse mackerel (Trachurus trachurus) and the southern shortfin squid (Illex coindetii) are the most important prey, with a % IRI of 47.54 and 35.04%, respectively. The results revealed that there are no significant differences in the diet preferences among sexes and size classes. However, diet composition varied significantly among months. A significant correlation was found between the body length of predator and prey size. The remarkable decrease in the fullness index (fi) from June to August suggests that swordfish were in a spawning condition, with reduced feeding.