The attack, on Sunday, was carried out by the Libyan air force after the ship’s movements aroused suspicion, a Libyan military spokesman told the BBC.
Derna has been controlled by Islamist militants for the past two years.
The Libyan military attacked the port several times last year in an attempt to weaken militant groups there.
The military spokesman, Colonel Ahmed Mesmari, said the tanker had been targeted because it had failed to submit to an inspection before entering the port.
He said the vessel was supposed to dock at a power plant in Derna but instead “took a different route”, entering a “military zone”.
“We asked the ship to stop, but instead it turned off all its lights and would not respond so we were obliged to strike it.
“We bombed it twice,” he said.
There were 26 crew members on board the ship, Araevo, including nationals from the Philippines, Greece and Romania.
Two were injured in the attack, in addition to those killed.
The Liberian-flagged tanker is operated by an Athens-based shipping company, Aegean Shipping Enterprises Company, and was carrying 12,600 tonnes of crude oil.
The Greek authorities said the ship was at anchor in the port when it came under attack.
Aegean Shipping said there was no leakage of oil and it was assessing the damage.
There has been no confirmation about the purpose of the ship’s visit to the militia-held area.
One report suggested the tanker was delivering fuel for power generators. Col Mesmari told Reuters the vessel had been bringing Islamist fighters to Derna.
“We had warned any ship not to dock at the port without prior permission,” he was quoted as saying.
Libya has been in chaos since its long-time leader, Colonel Muammar Gaddafi, was overthrown with Western military help in 2011.
Numerous militias govern their own patches of territory, with successive governments struggling to exercise control.
The competition for power and resources has led to frequent fighting and battles to control facilities, including ports, linked to Libya’s oil industry.
The internationally recognised government is based in Tobruk, near the Egyptian border, having been expelled from the capital, Tripoli, by militias in 2014.
A rival militia-backed administration now controls the capital while the second biggest city, Benghazi, is largely in the hands of Islamist fighters.