The bill, proposed by President Dilma Rousseff in the wake of violent and lengthy protests earlier this summer, had already been passed by the Senate.
The federal government had wanted to allocate all resources to education but a public outcry, which saw violent clashes between protesters and police in many Brazilian cities sparked by a rise in transport costs, forced a rethink.
The bill calls for 75% of royalties to be pumped into education with 25% to go to the health system.
The Senate’s vote on 2 July slightly altered the project that was approved by the Chamber of Deputies on 26 June, meaning the bill returned to the House for a second vote.
The bill approved in the Senate says that all oil royalties should be destined to education and health, regardless of concession terms or future production sharing contracts, provided the declaration of commerciality took place after 3 December 2012.