U.S. Defense Secretary Chuck Hagel (L) and Chairman of the Joint Chiefs of Staff Army Gen. Martin Dempsey testify before the Senate Armed Services Committee in the Hart Senate Office Building on Capitol Hill September 16, 2014 in Washington, DC. Senators questioned the top military and civilian leaders about the threat posed by the terrorist group calling itself the Islamic State of Iraq and the Levant or ISIL. Chip Somodevilla/Getty Images

The military's top officer told a Senate panel Tuesday that U.S. troops could end up fighting side by side with Iraqi troops against the Islamic State. Gen. Martin Dempsey said he would recommend ground troops to President Barack Obama if the military situation called for it, answering senators' questions on the militant group also known as ISIS.

"To be clear, if we reach the point where I believe our advisers should accompany Iraqi troops on attacks against specific ISIL targets, I will recommend that to the president," said Dempsey, the chairman of the Joint Chiefs of Staff. Dempsey said some Americans might be needed on the ground to direct airstrikes. The debate over whether to have U.S. troops on the ground in Iraq initially came up during the recent battle to secure the important Mosul dam, but Dempsey said he ultimately decided they were not needed for the operation.

Obama has publicly ruled out "boots on the ground" as part of the campaign to wipe out ISIS, but Dempsey said that could change if the situation warrants. Asked whether he agreed with the White House's strategy, Dempsey said he did. "Is in my judgment that it is the correct approach," he said, according to NPR.

Sen. James Inhofe, R-Okla., the ranking member of the Senate Armed Services Committee, countered that Obama's strategy was "fundamentally detached." "It will take an army to beat an army," Inhofe said.

Defense Secretary Chuck Hagel said during the hearing that he and other military leaders would share their plan to destroy ISIS with Obama Wednesday. Hagel said the U.S. will fund the training of more than 5,000 Syrian fighters in the first year to start the campaign. "Five thousand alone is not going to be able to turn the tide. We recognize that," he said.

The hearing was punctuated by anti-war protesters Tuesday morning who tried to drown out the testimony. Code Pink members shouted "no more war" and held signs with slogans such as "more war = more extremism."