Spain's King Felipe VI on Wednesday visited special forces helping Iraq fight Islamist extremists, during the first trip by a Spanish monarch to the war-ravaged country in four decades, a diplomat said.
The king, whose country is a member of an international coalition battling the Islamic State group, also later met President Barham Saleh.
Iraq in 2017 declared victory over the IS group following a bruising months-long campaign backed by the coalition, which continues to carry out operations against the group.
Spain, which took part in the US-led 2003 invasion of Iraq that overthrew dictator Saddam Hussein, went on to support Iraqi troops as they battled to roll back the IS group, which seized a third of the country including second city Mosul in 2014.
Hundreds of Spanish military instructors remain in the country.
King Felipe is one of a series of leaders to visit Baghdad since the start of the year, including US President Donald Trump, who drew criticism for failing to meet a single Iraqi official.
Baghdad has also hosted the chief diplomats of its two main allies, Washington and Tehran -- themselves bitter enemies.
Iraq's precarious position has been complicated by Trump's shock decision last month to pull troops from neighbouring Syria.
That has prompted pro-Iran factions to intensify their calls for an accelerated withdrawal of US troops from Iraq.
*This story was edited by Ahram Online