After a long battle with Congress that went down to the wire, President Bush signed a renewal of the USA Patriot Act on Thursday, a day before 16 major provisions of the old law expire.

Bush said the Patriot Act is vital to win the war on terror and protect Americans. He recalled the terrorist attacks of Sept. 11, 2001, and said the country is still at war.

"We saw the terrorists' destructive vision for us when they killed nearly 3,000 men, women and children," Bush said. "In the face of this ruthless threat, our nation has made a clear choice — we will confront this mortal danger, we will stay on the offensive and we're not going to wait to be attacked again."

Bush's signature came less than 48 hours after the House passed the legislation, ending several months of debate on Capitol Hill over how to balance Americans' right to privacy with a need to foil potential terrorist threats. Political battles over the legislation forced Congress to twice extend the expiration date of the Patriot Act.

"The Patriot Act has accomplished exactly what it was designed to do," Bush said during a signing ceremony in the White House East Room. "It has helped us detect terrorist cells, disrupt terrorist plots and save American lives."

Republicans want to take the law into the upcoming midterm elections to show they are acting to protect national security.

The legislation renews the expiring provisions of the original Patriot Act, including one that lets federal officials obtain "tangible items," such as business records, from libraries and bookstores, in connection with foreign intelligence and international terrorism investigations.

Other provisions clarify that foreign intelligence or counterintelligence officers should share information obtained as part of a criminal investigation with counterparts in domestic law enforcement agencies.

Yet another provision is designed to strengthen port security by imposing strict punishments on crew members who impede or mislead law enforcement officers trying to board their ships.

To get the legislation renewed, Bush was forced to accept new curbs on the Patriot Act's powers.

These new civil liberties protections for the first time say explicitly that people who receive subpoenas granted under the Foreign Intelligence Surveillance Act for library, medical, computer and other records can challenge a gag order in court.

The compromise, crafted by Sen. John Sununu, R-N.H., also removes a requirement that a person who receives a National Security Letter provide the FBI with the name of an attorney they have consulted. These letters are subpoenas for financial and electronic records that can be issued without consulting a judge.

Thirdly, the Sununu compromise clarifies that libraries in most cases are not subject to these letters.