WASHINGTON, DC - JUNE 24: From L, Senate Minority Leader Mitch McConnell (R-KY), Senate Majority Leader Harry Reid (D-NV), and Speaker of the House John Boehner (R-OH) lock arms as they sing 'We Shall Overcome' during a ceremony to posthumously award the Congressional Gold Medal Dr. Martin Luther King, Jr. and Coretta Scott King, on Capitol Hill, June 24, 2014 in Washington, DC. The Congressional Gold Medal is Congress's highest civilian honor. (Drew Angerer/Getty Images) And although a majority of Americans hold negative opinions of both parties, an overwhelming majority continues to take one side or the other. (Drew Angerer/Getty Images)

WASHINGTON (AP) — To hear congressional Republicans tell it, Democrats are so eager to grant work permits to immigrants in the U.S. illegally that they’d risk funding for the Homeland Security Department to do it. Democrats counter that it’s Republicans who are jeopardizing the Homeland Security budget in their zeal to deport immigrants brought here illegally as children.

Those two opposing sides are in a high-stakes drama underway on Capitol Hill as lawmakers wrangle over a $39.7 billion House-passed bill that funds the department for the remainder of the budget year while overturning President Barack Obama’s executive actions limiting deportations for millions here illegally and giving them the ability to work.

The back-and-forth comes at a time of global threats and terrorist slayings of prisoners. One way or another, most involved agree, Congress will find a way to approve funding for the Homeland Security Department, even if lawmakers have to pass a short-term extension ahead of the Feb. 27 deadline before coming up with a final deal.

But how and when lawmakers will get there is less clear as both parties jockey for advantage in a new era of divided government, with Republicans in full control of Congress for the first time in eight years and Obama ready and willing to wield his veto pen.

“It’s so hard to divine how this will all come out,” said Rep. Trent Franks, R-Ariz.

It was a comment echoed Tuesday by lawmakers at both ends of the Capitol as Senate Democrats united against a procedural vote that would have opened debate on a House-passed bill. A total of 51 Republicans voted to advance the bill — short of the 60 needed — while all 44 Democrats, two independents and two Republicans were opposed.

Republicans indicated there would be more votes on the measure in the days to come, and Democrats promised the result would not change unless Republicans removed the language on immigration. In the end, Democrats predicted, Republicans would do just that.

“The Republicans should stop the posturing for the right wing of their party and stand down and do what’s right,” said Senate Minority Leader Harry Reid, D-Nev. “They’ll wind up passing a clean bill, so why stop — why do we wait?”

Some Republicans acknowledged privately, and a few publicly, that outcome was likely. “Ultimately there may be a clean bill,” said Rep. John Carter, R-Texas.

But before that could be entertained, House conservatives said they had to be convinced that Majority Leader Mitch McConnell, R-Ky., and his Senate Republicans had exhausted every tactic against what they described as an unconstitutional overreach by Obama. Complicating matters for GOP leaders, not every Republican agreed that it was absolutely essential to keep the Homeland Security Department funded.

“It’s obviously not the end of the world” for the agency to lose funding, GOP Rep. Matt Salmon of Arizona said Tuesday, because most department personnel would be deemed essential and keep working.

House Republicans were casting about for another solution, such as splitting up the funding bill, Salmon said. He said a lawsuit over Obama’s immigration actions, as House Speaker John Boehner has said is possible, wouldn’t satisfy conservatives.

In the Senate, Republicans including moderate Susan Collins of Maine were also looking for a way out. Collins said she was working with Sen. Ted Cruz, R-Texas, and others on alternate legislation to fund the Homeland Security Department and roll back the new administration policies limiting deportations, but keeping in place protections for immigrants brought to the U.S. as children.

“I think it’s a good solution and a way to resolve an impasse that has the potential to cause some real harm,” Collins said in an interview.

But with Democratic leaders pledging to oppose any Homeland Security spending bill with immigration language attached, it was not clear whether Collins’ proposal would shift the debate. That was especially true with Democrats seeing their stance as good politics in a presidential election cycle in which Latino voters are likely to play an important role.

Obama invited to the White House a group of younger immigrants who would be subject to eventual deportation under the House-passed bill. During the Oval Office meeting Wednesday with the “Dreamers,” Obama was expected to defend his policies and criticize the GOP.

(© Copyright 2015 The Associated Press. All Rights Reserved. This material may not be published, broadcast, rewritten or redistributed.)