NATO forces are staying in Iraq at the country's request, alliance chief Jens Stoltenberg said during a rare visit on Monday to Baghdad, after parliament called for a foreign troop pullout.

"We are here because Iraq wants us to be here. We are not here without the consent and without an invitation from Iraq," Stoltenberg told AFP news agency on Monday.

"We should not stay longer than necessary, we will train the trainers as long as necessary to make sure IS [Islamic State of Iraq and the Levant] does not reemerge."

Stoltenberg's comments come days after the Iraqi parliament called for the government to draw up a timetable for the withdrawal of foreign troops from the country.

"The Iraqi parliament expresses its gratitude to all countries which have supported Iraq in its fight against Daesh [ISIL] and calls for the government to draw up a timetable for the withdrawal of foreign troops," it said in a statement.

Iraqi Prime Minister Haider al-Abadi declared in December the end of the war to expel ISIL fighters from the country, three years after they seized one-third of Iraq, sweeping aside security forces in rapid succession.

'Helping ourselves'

Stoltenberg visited a NATO training facility in Iraq and met Abadi weeks after NATO defence ministers agreed on a bigger "train-and-advise" mission in the country.

"All 29 allies want NATO to play a bigger role in fighting terrorism because terrorism affects all of us. It's been a clear message from the Trump administration, but also from the other allies," Stoltenberg said.

"This is about helping Iraq, but also about helping ourselves."

He also praised the "enormous transformation" of Iraqi forces since 2014, when ISIL launched its lightning offensive and seized swathes of territory.

"The Iraqi forces in 2014 are totally different from the Iraqi forces in 2018," the NATO chief said.

As combat operations wind down after three years of war against ISIL, the NATO mission set to start in July will focus on bomb disposal, military medicine, and reforming security institutions, including fighting corruption, he said.