The bill also includes an unrelated provision that seeks to strengthen laws that forbid most online gambling.
Mr. Bush used the bill-signing ceremony to assert that Republicans are tough on terror, a key issue in congressional elections just less than four weeks away.
"We're going to protect our ports. We're going to defend this homeland, and we're going to win this war on terror," Mr. Bush said.
He did not mention the gambling provision. Instead, Mr. Bush focused on the multiple ways the legislation tightens security and closes a loophole in anti-terror defenses, especially at ports.
Congress approved the bill two weeks ago, one of its last acts before lawmakers left to campaign for the Nov. 7 congressional elections in which national security, the war in Iraq and terrorism are expected to be major factors.
The administration has spent about $10 billion to enhance security at U.S. ports since the Sept. 11 attacks. About 65 percent of cargo, that is considered most high-risk, is screened for nuclear or radiological materials. The Homeland Security Department aims to increase that number to 80 percent by the end of the year and to almost 100 percent by the end of 2007.
The issue became a particular priority for Congress after a fight in February over a buyout that put a Dubai company in control of some operations at six U.S. ports. The outcry led the Dubai company, DP World, to promise it would sell the U.S. operations to an American company. The sale is pending.
Democrats favored the bill, but said it failed to address rail and mass transit, other areas considered highly vulnerable to terrorist attack. The bill was approved on a 409-2 vote in the House, and by a voice vote in the Senate.
The legislation approves $400 million a year over five years for risk-based grants for training and exercises at ports. It requires the nation's 22 largest ports, which handle 98 percent of all cargo entering the country, to install radiation detectors by the end of next year.
Pilot programs would be established at three foreign ports to test technology for nonintrusive cargo inspections. Currently only one foreign port, Hong Kong, scans all U.S.-bound cargo for nuclear materials.
Background checks and credentials will be required for workers at the nation's 361 ports, and the Homeland Security Department would set up protocols for resuming operations after an attack or incident. It is feared that a terrorist attack, such as a nuclear device set off by remote control, could cripple the entire economy as well as cause massive casualties.
Preferential cargo processing is offered to importers who meet certain security requirements.
The Internet gambling provision tackles the difficult task of enforcing bans by prohibiting players from using credit cards, checks and electronic fund transfers to settle their online wagers.
CBS News correspondent Jim Acosta reports the measure could topple a $12 billion a year juggernaut that gives amateurs a taste of the action on those wildly popular TV poker tournaments.
Conservative groups said the sites prey on gambling addicts, operating offshore, under the radar of law enforcement.
"It's necessary because of the damage that we have seen, gambling and especially anonymous gambling on the Internet," said Tom McClusky of the Family Research Council.
The new law won't make it a crime to play poker online; instead it blocks banks from processing gambling winnings – which is why players are now cashing in their virtual chips.
While Jeff Markley, with the gambling trade magazine Bluff, has closed his online poker accounts, he says players are plotting ways to move their winnings through third-party web sites.
"They are never going to be able to stop the means of funding gambling accounts," Markley says.
Industry observers fear many Internet gamblers will simply turn to black market on-line casinos.
"The bad thing about the law is that it really drives out the operators who would be the most reputable," says David Schwartz of the Center for Gaming Research at the University of Nevada, Las Vegas.