This will be the heavily delayed sixth package of sanctions, something which the president of the European Council, Charles Michel, called a "remarkable achievement."
The ban "will effectively cut around 90 percent of oil imports from Russia to the EU by the end of the year," said Ursula von der Leyen, the president of the European Commission.
She also said that the EU had agreed to make a "massive investment in renewable energy" in order eliminate their dependence on Russia.
Additionally, EU foreign policy chief Josep Borrell tweeted: "A landmark decision to cripple Putin’s war machine. Our unity is our strength."
The ban will include seaborne oil purchases, of both oil and petroleum products, but temporarily exempts the Russian oil delivered by pipeline, so that countries like Hungary, Slovakia, and the Czech Republic can buy more time to phase off crude oil supplies from Russia.
This exemption was a key demand made by Hungary, given that its economy heavily relies on Russian oil delivered via the Druzhba pipeline.
Hungarian Prime Minister Viktor Orbán also got guarantees that his country would still be able to purchase Russian oil from alternate sources if there was an "accident" with the Druzhba pipeline, because it crosses Ukraine.
The EU has already banned Russian coal imports but waited until now to take the same action on gas.
The agreement comes in the backdrop of Gazprom, the Russian state-owned energy company, cutting gas supplies to the Netherlands. It has already done the same to Poland, Bulgaria, and Finland.
(With inputs from Reuters and the Financial Times.)