The nation’s top military officer raised the possibility Tuesday that U.S. troops could become involved in ground attacks against the Islamic State, despite repeated pledges to the contrary from President Obama.

In testimony before the Senate Armed Services Committee, Army Gen. Martin Dempsey, the chairman of the Joint Chiefs of Staff, sketched out scenarios in which U.S. Special Forces might need to embed with Iraqi or Kurdish troops engaged in direct combat with Islamic State fighters.

Under questioning from lawmakers, Dempsey acknowledged that Obama has vowed not to send U.S. ground combat forces back into Iraq, less than three years after the president fulfilled a campaign promise to extricate the military from a long, costly and unpopular war there.

But the general revealed that U.S. commanders have already sought permission, on at least one occasion, to deploy small teams of U.S. advisers into battle with Iraqi troops. Dempsey also suggested that while Obama has held firm, he might be persuaded to change his mind.

“He has told me, as well, to come back to him on a case-by-case basis,” Dempsey said. “If we reach the point where I believe our advisers should accompany Iraqi troops on attacks against specific [Islamic State] targets, I’ll recommend that to the president.”

The uncertainty of exactly what role U.S. troops might play in Iraq and Syria comes as Congress prepares to vote on Obama’s request for approval to train and equip about 5,000 moderate Syrian rebels to fight the Islamic State.

The House resolution, expected to come to a vote Wednesday, explicitly says it does not support U.S. forces on the ground. The resolution is likely to be approved with bipartisan support and be included in a broader government funding bill that will make it to the president’s desk by the end of the week, lawmakers said.

The question of ground forces, however, will probably become a central focus of a legislative debate about war powers that is expected to begin after the Nov. 4 elections.

Since June, Obama has ordered the deployment of 1,600 U.S. troops to Iraq in an effort to bolster the country’s faltering army and stop the Islamic State’s advance.

Even as the mission has gradually expanded and the U.S. military has launched 167 airstrikes against the Islamic State, Obama and other White House officials have consistently promised that U.S. troops will not engage in ground combat.

Dempsey told lawmakers that U.S. military advisers are helping Iraqi government forces prepare for a major offensive to reclaim territory seized by the Islamic State in recent months. Those advisers are embedded with Iraqi and Kurdish forces at the brigade or headquarters level — away from the front lines.

Dempsey testified that Army Gen. Lloyd Austin, the commander of U.S. troops in the Middle East, wanted to embed U.S. troops with Iraqi and Kurdish security forces last month during a battle to retake control of the Mosul Dam from the Islamic State.

According to Dempsey, Austin wanted the U.S. troops to help call in airstrikes. The Joint Chiefs chairman suggested that Austin was overruled, saying the commander changed his mind after further discussions and “found a way” to organize the operation without U.S. personnel present.

At the same time, Dempsey said he and Austin agreed that more situations will arise when military commanders will want to put U.S. Special Forces or airstrike spotters on the ground. “There will be circumstances when we think that will be necessary, but we haven’t encountered one yet,” Dempsey said.

By openly suggesting that U.S. ground combat forces will be needed, Dempsey was walking a fine line between questioning the judgment of Obama, the commander in chief, and sharing his own professional military opinion with lawmakers and the public.

Dempsey said he did. But he added that if the current approach were to falter, he might recommend a different one, possibly including “the use of U.S. military ground forces.”

Later, he also said he might recommend that U.S. troops provide “close combat advising” to Iraqi forces if they were to attempt a complex mission, such as retaking the northern city of Mosul from the Islamic State.

Obama is scheduled to meet with Austin and Defense Secretary Chuck Hagel on Wednesday at the U.S. Central Command headquarters in Tampa. Earlier this month, Obama ordered an expansion of airstrikes, adding that it was time to “start going on some offense” against the Islamic State.

After Dempsey finished his testimony, the White House reiterated that Obama remained opposed to sending U.S. ground troops into combat in Iraq or Syria.

Josh Earnest, the White House press secretary, told reporters that Dempsey’s remarks referred to “a hypothetical scenario” and that it was the military’s responsibility to plan for a wide range of contingencies.

The debate about whether to send U.S. troops back into combat in Iraq— and possibly into Syria — is sensitive politically but in some ways a matter of semantics.

Air Force and Navy pilots already are firing missiles and dropping bombs on Islamic State fighters in Iraq. And although the 1,600 U.S. troops on the ground in Iraq have not engaged in firefights with the Islamic State, they are armed and authorized to defend themselves.

But the issue also cuts to the heart of Obama’s military strategy for fighting the Islamic State — and whether U.S. forces should take a leading and visible role on the ground or leave the fighting to Iraqi and Kurdish troops, as well as proxy forces in Syria.

Dempsey said the Obama administration’s plan to train and equip 5,000 Syrian rebels would take time — up to five months to establish the program and as long as a year to recruit, vet and train the fighters. Much of the training is expected to take place in Saudi Arabia.

Sen. John McCain (R-Ariz.) pressed Dempsey and Hagel on whether the U.S. military would intervene in Syria to aid the rebels if they were pinned down by forces loyal to Syrian President Bashar al-Assad. The two Pentagon leaders replied that the primary purpose of training the rebels was to help them fight the Islamic State, not Assad.

Earlier in the hearing, Hagel told lawmakers that “we are at war” with the Islamic State and warned that “this will not be an easy or brief effort.”

Some lawmakers urged the Pentagon and White House to act more aggressively. Sen. James M. Inhofe (R-Okla.) said it was “foolhardy” for Obama to rule out ground troops to advise Iraqi forces in combat and help call in U.S. airstrikes.

“His claim of ‘no boots on the ground’ is an insult to the men and women in Iraq today who are serving in harm’s way,” Inhofe said.

The United States had held off on further military assistance to Baghdad until a new broad-based government is formed, but Iraqi politicians are still wrangling over who should hold the key positions of minister of defense and interior.

Abadi had pledged to fill the defense and interior posts, and four other ministerial positions left open when the government was formed a week ago, by Tuesday. However, there has been fierce debate about who should steer the security posts amid the violence racking the country.

Paul Kane in Washington and Loveday Morris in Baghdad contributed to this report.

Sign up for email updates from the "Confronting the Caliphate" series.