(CNN) -- Days after refusing to rule out recommending U.S. combat troops in Iraq, the chairman of the Joint Chiefs of Staff made an unexpected trip Saturday to the turbulent Middle Eastern nation to talk with officials there about combating ISIS, an official said.
Gen. Martin Dempsey traveled to Iraq "to confer (with) Iraqi political and security officials on next phase of the campaign to defeat (ISIS)," according to a tweet from Brett McGurk, a U.S. diplomat focused on ISIS as well as Iran and Iraq.
Pentagon spokesman Jim Gregory added that Dempsey met with Prime Minister Haider al-Abadi, as well as U.S. Ambassador Stuart Jones and U.S. troops and commanders in the country.
"The primary purpose of his visit is to get a firsthand look at the situation in Iraq, receive briefings, and get better sense of how the campaign is progressing," said Gregory.
During the meeting between Dempsey and al-Abadi, the two discussed the fight against ISIS, including new developments and progress made by Iraqi forces, according to a statement from the Prime Minister's office.
The troops' victories are part of a strategic plan for liberating all Iraqi territory, and it will be achieved, al-Abadi said.
After his Baghdad stop, Dempsey moved north to Irbil, the capital of Iraq's Kurdish region and home to U.S. military advisers and consular personnel. The Joint Chiefs chairman met there with Nechirvan Barzani, the prime minister of the semi-autonomous region, according to Gregory.
Until recently, the Kurdish region had been the most stable in Iraq and a cooperative ally of the United States. But it came under an onslaught earlier this year from ISIS, one that -- so far, at least -- it has been able to withstand.
Dempsey's entire trip, which wasn't announced beforehand, is the first since the U.S. military earlier this year launched Operation Inherent Resolve. That's what Washington is calling its military campaign against ISIS, which consists largely of U.S.-led airstrikes against the terrorist group as well as support for the Iraqi military.
Christopher Harmer, an analyst with the Institute for the Study of War, said Saturday that it's very important for U.S. military leaders like Dempsey to get away from Washington and see for themselves how this fight is going.
"I think what General Dempsey is doing here is sending a message both to the U.S. troops that he understands what's happening, that he wants to get firsthand knowledge of what's happening," Harmer said. "And (he is) also sending a message to our allies, the Iraqi government, that he's taking this seriously and that we're committed to an ultimate victory on their behalf."
Dempsey has been one of President Barack Obama administration's leading voices on the situation in Iraq, where ISIS -- which calls itself the Islamic State -- has taken over wide swaths of territory, reportedly terrorizing citizens in the process.
Obama has made going after ISIS a top priority in recent months, including expanding coalition airstrikes against the Islamist extremist group into neighboring Syria. Yet he has insisted that American combat troops won't play a role in Syria or in Iraq, though military advisers have recently been sent to Iraq.
Yet in testimony Thursday to the House Armed Services Committee, Dempsey said he would not rule out asking the President to send U.S. ground troops into Iraq. He told the committee that he could envision scenarios in which a U.S. ground contingent would be necessary there, particularly if the coalition moves to retake Mosul or the western border with Syria.
"I'm not predicting at this point that I would recommend that those forces in Mosul and along the border would need to be accompanied by U.S. forces," cautioned Dempsey, "but we're certainly considering it."
CNN's Laura Koran and Salma Abdelaziz contributed to this report.