Prospects for the contentious immigration bill that has been working its way through the Senate for months vastly improved Thursday after senators agreed to spend several billion more to fortify the U.S.-Mexico border.

Among other things, the agreement calls for doubling the number of federal border agents at a cost of about $30 billion.

The deal is expected to secure at least a dozen more Republican votes and could help ensure passage of the bill by the sizable margin that proponents have said they need to make it viable in the House of Representatives.

The border security agreement establishes several specific conditions that would need to be met before any of the 11 million immigrants in America illegally begin applying for residency status.

First, the Border Patrol will absorb a "surge" of 20,000 additional agents that Sen. Charles Schumer called "a breathtaking show of force that will discourage future waves of illegal immigration."

The federal government also will need to complete construction of about 1,100 km of fencing along the western sector of the border.

Changes in the E-Verify program that employers must use to verify a job applicant's immigration status will need to be in place, and a biometric scanning system to catch immigrants who overstay visas will need to be operational at the largest international airports.