A majority of 370 members of the European Parliament voted in favour of the bill, while 199 opposed and 46 abstained.
Buildings account for 40% of the European Union's energy use, and most are heated by fossil fuels. The new rules will lead to the upgrade of buildings to use less energy - a move that also aims to wean countries off Russian gas faster and curb households' bills.
"This law is going to help people to save money on their energy bills and take people out of energy poverty, while reducing emissions from our buildings and cutting demand for fossil fuel imports," said Green MEP, Ciaran Cuffe, who negotiated the law.
Under the new law, the EU's 27 member states will have to apply newly created standards to non-residential buildings, like offices or hospitals, and will be able to use EU funds to make them more energy-efficient.
"There is a lot of EU money ready to fund renovations," Cuffe said in a statement.
The standards may be applied to residential buildings as well, but there will be no obligation to renovate for individual homeowners.
The law was controversial after several countries such as Italy opposed, saying neither governments nor homeowners could afford the renovations.
Italian legislator Angelo Ciocca, whose party, Lega, belongs to Italy's ruling coalition, blew a whistle in the European Parliament on Tuesday in protest at the approval of the law, until he was taken out by security officers.