Spain's prime minister has started a two-day trip to two west African countries as Europe faces pressure from jihadis and migrants making perilous sea crossings seeking a better life.

Mariano Rajoy landed in Bamako, the capital of Mali, on Sunday and met with President Ibrahim Keita, the prime minister said on his official Twitter account, also posting photographs.

Speaking at a news conference, Rajoy said Spain was committed to defending "the freedom, rights and safety of all Spaniard" within Spain and overseas.

Rajoy said the previously unannounced trip was also to visit Spain's troops in the region.

Spain participates in EU missions to train the army in Mali and to monitor the coast of Senegal for possible migrant ships departing.

Rajoy said he would visit Senegal later Sunday.