Republicans and Democrats struggled Wednesday over the final details of an elusive deal that would grant quick legal status to millions of illegal immigrants living in the U.S. and fortify the border.

Among the sticking points was how much family ties should count toward green cards for future immigrants. Democrats and Republicans also haggled over how to treat a new temporary guest workers. For the most part, they would be barred from putting down roots or eventually gaining a path to permanent residency.

The emerging bipartisan compromise among senators and the White House would set the stage for a freewheeling Senate debate next week. The divisive issue is exposing deep rifts in both parties and carries political risks.

"The best way, and, frankly, the only way to get a comprehensive bill done that will matter and deal with this issue once and for all, is for the bipartisan approach that we're now working on to come to fruition," President Bush said.

With immigration overhaul a priority, Bush has sent Homeland Security Secretary Michael Chertoff and Commerce Secretary Carlos Gutierrez to weeks of private meetings with lawmakers.

"There is a good chance" of an agreement, Bush said.

Sen. Ted Kennedy of Massachusetts, the Democrats' lead negotiator, said a deal was imminent. Still, representatives on both sides complained that long-settled issues had returned as sticking points.

"I'm determined to get the job done and get it done right. We're close to the finish line and we need to keep moving forward," Kennedy said through a spokeswoman.

Liberals and conservatives alike are skeptical of the proposal.

Some Republicans contend it is too lenient in how it treats the estimated 12 million illegal immigrants. Some Democrats say the plan is too restrictive toward future immigrants and unfair to families.

Senate Majority Leader Harry Reid, D-Nev., said he was concerned with elements of the outline. He said interest groups were burning up his phone lines with complaints.

"Our immigration system is broken and certainly needs to be fixed. But in the process we don't want to make it worse than what it was to start with," Reid said.

The proposed agreement would allow illegal immigrants to come forward and obtain a "Z visa." After paying fees, a $5,000 fine and then returning to their home countries, they could get on track for permanent residency, which could take between eight years and 13 years.

They could come forward right away to claim a probationary card that would let them live and work legally in the U.S. They could not, however, begin the path to permanent residency or citizenship until completion of border security improvements and a high-tech worker identification program.

That was an important goal for Democrats, who are eager to allow undocumented immigrants to adjust their status as soon as possible.

A new temporary guest worker program would have to wait until those "triggers" had been activated. This is a priority for conservatives, who had insisted on strengthening the border before they would act on a broader immigration bill.

All but the highest-skilled temporary workers would have to return home after work stints of two years or three years, with barely any opportunity to apply for permanent legal status or ever become U.S. citizens.

Only 10,000 green cards annually would become available for guest workers. The cards would be awarded on a "points system" that favors higher-skilled and better-educated immigrants.

Negotiators were considering specifics about the guest worker program, including the length of the visas and how many times to allow workers to renew them. Democrats were pressing for guest workers to be allowed to stay and work indefinitely in the U.S.

In perhaps the most hotly debated change, the proposed plan would shift from an immigration system heavily weighted toward family ties toward one with preferences for people with advanced degrees and sophisticated skills.

Family connections alone would no longer be enough to qualify for a green card — except for spouses and minor children of U.S. citizens. Senators were trying to decide how heavily to weigh family ties in the points system.

New limits would apply to U.S. citizens seeking to bring foreign-born parents into the country. Democrats were working to get additional preferences for family members.

"The point system that they have — unless they change it — is quite pointless," Reid said.