The bill's approval came one day before President Luiz Inacio Lula da Silva was set to meet his US counterpart Donald Trump at the White House, where the pair will discuss the coveted minerals among other things.
Brazil holds the world's second-largest reserves of these elements used in everything from electric vehicles, solar panels and smart phones to jet engines and guided missiles.
The complex process of separating rare earth minerals is currently dominated by Chinese companies, but the United States is seeking to catch up and has expressed interest in Brazilian reserves.
Lula views foreign investment in a positive light but has insisted that rare earths be processed within Brazil rather than exported as raw materials.
The text was approved with majority support from both the ruling party and the opposition.
It grants the government the power to veto agreements with foreign companies "that may affect the country's economic or geopolitical security," as well as the right to approve "changes in corporate control" of companies in the sector.
The law, set to be debated by the Senate, also provides tax incentives for mining companies.
Lawmaker Arnaldo Jardim said the bill allowed Brazil to go beyond exporting minerals and "use this geological attribute as a clear instrument for development."
Greenpeace criticized the bill's approval for "lacking in transparency, without broad debate involving civil society, experts or potentially affected communities."
"Everything suggests that the text is being drafted to please the mining industry," said Gabriela Nepomuceno, public policy specialist at Greenpeace Brazil.