Al-Hakim's remarks followed a meeting with French Foreign Minister Jean-Yves Le Drian in Baghdad and comes amid international concern about the fate of thousands of IS members held by Kurdish fighters in Syria.
Kurdish-led forces in Syria are warning that they might not be able to adequately guard some 10,000 IS fighters because of Turkey's ongoing military operation into northern Syria, which began last week. That has raised fears of potential IS jailbreaks.
Over the weekend, 780 IS supporters fled a camp for the displaced in the Syrian town of Ein Issa. The IS fighters that the Kurdish-led Syrian Democratic Forces are holding include some 2,000 foreigners, including about 800 Europeans. The nearly 8,000 left are Iraqis and Syrians. The SDF is also holding tens of thousands of women, many of them wives and widows of IS members, and their children.
IS once held large parts of Iraq and Syria, where the extremists declared a so-called caliphate in 2014. IS was defeated in Iraq two years ago and in Syria in March but the extremists' sleeper cells have continued to carry out attacks in both countries.
"We discussed the situation in Syria and Iraq is taking all measures to prevent foreign fighters from crossing through the border into Iraq," al-Hakim said. He said of Iraqi IS fighters and their families: "We will bring them and they will be put on trial."
Al-Hakim said foreign fighters come from 72 countries and "their countries should take the needed measures." Influential Iraqi Shiite cleric Muqtada al-Sadr had called on the Iraqi government not to take foreign fighters, saying "we are not ready to spend money on them."
Le Drian, the French foreign minister, warned that the Turkish offensive "is threatening the gains that were achieved against IS." Le Drian later met President Barham Saleh, who called on the international community to support Iraq so that it can preserve its security by preventing IS from resuming its activities.
The meetings in Baghdad came a day after French President Emmanuel Macron said IS foreign fighters who might flee Syrian detention centers and go to Iraq should be arrested and sent to trial there. Macron said "it's too soon" to say if some members of IS may seek to reach the European Union and France.
On Wednesday, Iraq's defense minister expressed concerns that IS could take advantage of Turkey's invasion to destabilize Iraq, saying that a number of militants have been able to escape detention in Syria amid the chaos and cross into Iraq.
Najah al-Shammari urged the Iraqi government to work quickly on sealing the border. He did not elaborate or say how many IS members have crossed into Iraq adding that some of them are still at large while others have been detained.
Also on Wednesday, an official with an organization that assesses terror threats in Belgium told a parliamentary committee that at least two Belgian militants fled their detention center in Syria. Paul Van Tigcheld, head of Belgium's threat analysis organ, OCAD, told the committee Wednesday that five foreign terrorist fighters, three women and two men, who were in camps or prisons are no longer there.