Countries will now have to notify the Commission before starting negotiations on any oil and gas-related intergovernmental agreements with non-member states, and then take account of the Commission's opinion before signing the agreement.
The rule is part of a sustainable energy security package and aims to strengthen the EU's resilience to power supply disruption.
Under current rules agreed in 2012 countries must notify the Commission of such energy agreements, but only after they have been signed.
The new rules stipulate that the Commission may advise a member state on how to ensure an agreement is compatible with EU law, and may also participate in negotiations as an observer, with the written approval of the member state.
The Commission will then have five weeks to inform the member state of any concerns that it has about the deal, and 12 weeks to give an opinion on its compatibility with EU law.
If the member state does not take account of the Commission's opinion it must explain its decision in writing.
Rapporteur Zdzisław Krasnodebski said: "This legislation will ensure the energy security of the member states, creating effective ex-ante mechanisms for the European Commission to check draft agreements on gas and oil supplies, and to verify their compliance both with the EU law and with energy security needs."
EU member states agreed to the plan in December 2016.
Of the 124 agreements notified since 2012, one third of agreements relating to energy infrastructure or supply contained provisions that were not compliant with EU law, the Commission said.