Brazil's Congress has approved legislation aimed at modernizing and expanding the country's overcrowded ports and attracting private investments in the sector.

The legislation approved Thursday night allows the private sector to invest in state-owned ports and lifts restrictions that have hindered the building of private terminals.

It eliminates a rule that forced private companies with their own terminals to only handle their own cargo. They now can handle third-party goods.

The government says the legislation will help eliminate bottlenecks that have had hurts exports such as soybeans.

It is part of a government plan to invest 54 billion reals ($27 billion) to make the country's ports more efficient and improve the competitiveness of Brazilian exports by reducing freight costs by 20 percent.