The White House said Bush would sign the bill.
Nancy Pelosi, speaker of the house, said: "With this bill, we will be ... honouring the work of the 9/11 commission and we will be making the American people safer."
Bennie Thompson, chairman of the homeland security committee, said: "Congress is finally embracing what the 9/11 families have been saying all along.
"It takes a willingness to do things a different way."
The bill elevates the importance of risk factors in determining which states and cities get federal security money and puts money into a new programme to assure that security officials at every level can communicate with each other.
It would require screening of all cargo on passenger planes within three years and sets a five-year goal of scanning all container ships for nuclear devices before they leave foreign ports.
Bush had earlier threatened to veto the legislation over a provision that would have allowed union rights for 45,000 airport workers.
The White House agreed to sign the bill after Democrats backed away from that demand.
Republicans also won a provision that would give lawsuit protection to people who report suspicious activity near transportation systems.
The completion of the bill, however, was seen as a victory for Democrats, who have seen efforts on immigration and energy reform, as well as stem cell research funding thwarted by Republican and presidential resistance and House-senate differences.
The independent September 11 Commission in 2004 issued 41 recommendations covering domestic security, intelligence gathering and foreign policy, some of which have been implemented.
Democrats, after taking over control of congress, promised to make completing the list a high priority.
The most controversial provision in the legislation requires the radiation scanning of cargo containers in more than 600 ports from which ships leave for the US.
The White House, and other critics, say that the technology is not there, that the requirement could disrupt trade and that current procedures including manifest inspections at foreign ports and radiation monitoring in US ports are working well.
Critics also point out that 100 per cent screening will be costly.
Supporters argue that the unthinkable devastation from the detonation of a nuclear device in an American port makes it imperative to scan cargo before it reaches US shores.
As a compromise, it was agreed that the homeland security secretary can extend the five-year deadline for 100 per cent scanning in two-year increments if necessary.