Washington (CNN) The Supreme Court appeared closely divided along ideological lines during oral arguments Monday in a case that could determine President Barack Obama's legacy on immigration.

Conservative justices questioned Obama's authority to use executive actions to shield some 4 million undocumented immigrants from deportation. Chief Justice John Roberts and Justice Samuel Alito seemed particularly concerned with language in the administration's guidance that said the program's recipients would be "lawfully present," which they suggested would contradict immigration law.

"How is it possible to lawfully work in the United States without lawfully being in the United States?" Alito asked.

Roberts added: "I mean, they're lawfully present, and yet, they're present in violation of the law?"

Liberals on the bench seemed sympathetic to the administration's arguments. Justice Ruth Bader Ginsburg noted at one point that there are 11.3 million undocumented aliens in the country and Congress has provided funds for removing about 4 million. "So inevitably, priorities have to be set," she said.

Justice Sonia Sotomayor said there are not enough resources to deport everyone. "They are here whether we want them or not," she said.

Obama announced the moves to great fanfare in late 2014, as a response to congressional inaction on immigration reform. But a federal court blocked them after Texas and 25 other states sued.

Busloads of immigrants' rights activists -- some of them undocumented -- appeared on the court's plaza to support the policies. The moves are meant to shield them from deportation and allow them work permits.

Nancy Garcia, a U.S. citizen from Milwaukee, who was protesting with the Wisconsin group Voces de la Frontera (Voices from the Border), said she became active on the issue after Wisconsin lawmakers tried to crack down on undocumented immigrants.

"We're not drug lords. We're not rapists. We're good people," Garcia said.

Tea Party Patriots member Gregg Cummings said he arrived at 6 a.m. to find a spot in front of the court to protest the executive actions. Cummings, from Lamoni, Iowa, said he is concerned about the prospect of Obama's Supreme Court nominee, Judge Merrick Garland, changing the ideological balance of the court.

"Our number one purpose of being here is supporting the senators better standing strong on no votes on the new Supreme Court justice," he said.

Critics of Obama's moves say they are part of a pattern of the White House looking to go around the Republican Congress.

"Basically the President has stepped in and taken over what normally would be associated with Congress," Texas Attorney General Ken Paxton said in an interview. "Congress makes the laws."

Roberts also seemed concerned with the scope of the government's argument defending Obama's moves. "Under your argument, could the President grant deferred removal to every unlawful -- unlawfully present alien in the United States right now?" he asked Solicitor General Donald Verrilli.

At one point, Justice Anthony Kennedy suggested that the president might have strayed into Congress' territory. "It's as if -- that the President is setting the policy and Congress is executing it," he said. "That's just upside down."

The GOP Congress was involved at oral arguments as well. The House of Representatives, in an unusual move, intervened in the case against the administration, and had 15 minutes before the eight justices.

That only eight justices are hearing the case -- due to the death in February of Justice Antonin Scalia -- could impact the final result. A split court between the four Democratic-appointed justices and four GOP-appointed justices would mean the programs remain blocked and the case is sent back to the district court in Texas that blocked them in the first place.

Standing issue on center stage

For the administration, a key argument before the court is to say that the states do not have the legal right to bring the case in the first place. If it can convince a majority of justices on that issue, the court may not even get to the merits of the immigration debate.

All eyes were on Roberts, who has in past cases sometimes limited who can bring challenges to court. On Monday, he asked some critical questions of the government's position, but it was unclear how interested he might be in dismissing the case on standing.

"The question is: Does Texas have the right to bring this case?" said CNN Senior Legal Analyst Jeffrey Toobin. "Texas says if you give legal status to these people, then we'll have to give them drivers licenses. The federal government says there's nothing in this law about drivers licenses. This law is directed entirely at the immigrants themselves, it does not impose any obligations on the states. So the states should not have the right to challenge it. That's the standing argument. I think the Obama administration thinks they have a better chance at winning over one of the conservatives on standing than they do on the merits of the case."

Elizabeth Wydra, President of the Constitutional Accountability Center, who filed a brief in support of the government says she wouldn't write off the chief justice on the merits of the case or on the issue of standing.

"On the merits, Chief Justice Roberts' concerns seemed to be alleviated when the Solicitor General clarified that undocumented immigrants—given relief under the programs -- are simply afforded deferred action but none the less are subject to removal proceedings at any time the executive changes its enforcement priorities," she said.

Should it win on that count, the injunction would be lifted, and the programs would be able to go into effect during the final months of the Obama presidency.

However, because the actions can be changed or reversed by the next President, immigrants would have to decide whether to come forward for the remaining months of the Obama administration or risk doing so with the possibility of Donald Trump or Ted Cruz in the White House.

"There's no question that the ultimate fate of the deferred action policy hangs in the balance of the upcoming election," said Stephen I. Vladeck, a professor of law at American University and CNN Legal Analyst.

"Like any other executive order, it can be modified, rescinded, or expanded by the next President, and codified or overruled by the next Congress," Vladeck added. "But the fact that the Supreme Court expedited its consideration of the Obama administration's appeal so that it could resolve the dispute by June suggests that, even short-handed, the justices want to have their own say first."

Legacy issue for Obama

The White House announced the programs in November 2014, issuing a five-page guidance memo enabling qualifying undocumented workers to receive temporary relief from the threat of deportation and to apply for programs that could qualify them for work authorization and associated benefits.

The Deferred Action for Parents of Americans and Lawful Permanent Residents (DAPA) targets the nearly 4.3 million undocumented parents of citizens and lawful residents, and the second rule expands Deferred Action for Childhood Arrivals (DACA), initiative aimed at non citizens who came to the country as children.

"We'll bring more undocumented immigrants out of the shadows so they can play by the rules, pay their full share of taxes, pass a criminal background check and get right with the law," Obama told an audience in Nevada after the programs were announced.

The programs remain frozen nationwide. They were first blocked by a federal judge in Texas and a divided federal appeals court later upheld the preliminary injunction.

Obama's lawyers argue in court papers that the lower court rulings threatened great harm, "not only to the proper role of federal courts and to federal immigration law, but also to millions of parents of U.S. citizens and permanent residents, aliens who are the lowest priorities for removal yet now work off the books to support their families."

As a threshold issue, Verrilli says that the states don't have the legal right to be in court, because the Constitution "assigns the formation of immigration policy exclusively to the National Government precisely because immigration is an inherently national matter."

He stressed that the guidance from the government does not provide any kind of lawful status under immigration law as the aliens remain removable at any time.

"Immigrant communities fought for these programs," said Marielena Hincapié, the executive director of the National Immigration Law Center. She says that her groups have been informing people about the risks of the rules being changed by the next president and she believes many will come forward should the Obama administration win.

Texas Solicitor General Scott Keller argues that the states have standing to bring the challenge in part because DAPA would create a new class of recipients for state subsidized driver's licenses in Texas. He says that Texas would stand to lose millions of dollars if even a small fraction of DAPA eligible aliens applied.

"DAPA is an extraordinary assertion of executive power," Keller wrote in court papers. "The Executive has unilaterally crafted an enormous program -- one of the largest changes ever to our Nation's approach to immigration," he said. "In doing so, the Executive dispensed with immigration statutes by declaring unlawful conduct to be lawful."

He points to the guidance and says that the eligible undocumented immigrations would be permitted to be "lawfully present in the United States," which would make them eligible for work authorization and some types of Social Security and Medicare benefits.

Texas is supported by the GOP-led House of Representatives, who say that the programs went forward after the President failed in his attempts to persuade Congress to revise immigration laws.

Erin E. Murphy, a lawyer for the House, called the administration's position, "the most aggressive of executive power claims."

Andrew Pincus, a lawyer who supports the administration's position, says that allowing Texas to bring the case would have broad implications.

"If a state can sue every time the federal government does something to increase the state's costs, states could sue to challenge almost anything the federal government does," he said.

Pincus points out that Texas is not objecting to the administration's use of prosecutorial discretion, it just doesn't want the undocumented workers to be able to work legally.

"You are saying to these people, you can stay here, but we are keeping you in a bubble," he said.