The move puts Congress on a path to overriding President Bush's promised veto of a $38 billion homeland security spending bill.
The deal, approved by an 89-1 vote, resurrects a GOP plan to pass some of the most popular parts of Bush's failed immigration bill. That includes money for additional Border Patrol agents and fencing along the southern border.
Democrats liked the money. But they objected to Republican proposals such as allowing law enforcement officers to question people about their immigration status and cracking down on people who overstay their visas.
Efforts broke down Wednesday to make progress on a compromise containing only the border security money.
But Majority Leader Harry Reid, D-Nev., and Sen. John Cornyn, R-Texas, resolved their differences overnight and announced agreement Thursday morning. Cornyn won a promise to use some money to pursue immigrants who had entered the United States legally but had overstayed their visas.
Reid had apparently thought that Cornyn wanted harsher language.
"I was wrong and Sen. Cornyn was right," Reid acknowledged.
The measure initially was opposed by the White House, top Republicans said, and it clearly puts the president in a box. Bush had promised a veto of the overall homeland security bill for spending $2.3 billion more than he requested.
But the White House signaled it would at least accept the added money for the border.
"To the extent Congress supports additional emergency funding, we want to work with them to make sure it is spent on the highest border security priorities," White House spokesman Scott Stanzel said.
Now, Bush's stalwarts in Congress, including Sen. Judd Gregg, R-N.H., are poised to override the president's veto on the entire bill.
Cornyn predicted the bill would "pass by a veto-proof margin" and Sen. Lindsey Graham, R-S.C., told reporters the bill might get 90 votes in the 100-member Senate.
The measure probably will be the first spending bill for the budget year beginning Oct. 1 that will arrive on Bush's desk. The president, however, demanded on Thursday that the Democratic-controlled Congress focus on delivering the Pentagon's budget to him before lawmakers take their August vacation.
The money approved Thursday would go toward seizing "operational control" over the U.S.-Mexico border by using additional Border Patrol agents, vehicle barriers, border fencing and observation towers. In addition, there is Cornyn's effort against people who overstay their visas.
Graham said the $3 billion would pay for "more boots on the ground, more people patrolling our border making it harder for somebody to come across illegally. We should have done this a long time ago."
Bush and Republicans such as Graham and Sen. Jon Kyl of Arizona had argued during last month's immigration debate that a comprehensive approach to overhauling immigration policy was the only way to attract bipartisan support.
The bill was condemned by conservative talk radio and congressional foes as offering "amnesty." After it failed to pass, Graham and others changed their minds and offered the border security plan.
Graham and Kyl said the public will not accept the more contentious parts, especially the plan to give millions of illegal immigrants a way to earn U.S. citizenship, until the border with Mexico is made more secure.
"Border security is the gate that you must pass through to get to overall comprehensive reform," said Graham. The senator is up for re-election next year and faces political heat at home for backing Bush's unpopular immigration plan.
Sen. Arlen Specter, R-Pa., said he is circulating a plan that would grant some legal status to illegal immigrants but would stop short of giving them citizenship.
That approach "would take the teeth out of the amnesty argument," Specter said. "I think we can act this year. I think this bill is very close to doable."