A Turkish cargo ship has been shelled from the Libyan coast as it approached Tobruk port and then attacked from the air as it tried to leave the area, the Turkish foreign ministry said.

The ship's third officer died and other crew members were wounded in the attacks, which Turkey condemned on Monday, saying the ship was in international waters at the time.

A military spokesman for the UN-recognised government in Tobruk said the ship was bombed on Monday after it was warned not to break a ban on approaching the eastern city of Derna, and was later towed into Tobruk port.

"We have warned before about approaching Derna port," spokesman Mohamed Hejazi told the Reuters news agency.

Al Jazeera's Bernard Smith, reporting from Istanbul, said the ship was about 25km off Tobruk when it came under fire.

Our correspondent said the ship was carrying a shipment of plaster board.

It was the second deadly strike against merchant shipping by the Tobruk government's air force this year, and drew an angry response from Ankara.

The Turkish foreign ministry said it had lodged a protest with the Libyan authorities over the "atrocious" attack on the Cook Islands-flagged ship which had been travelling to Libya with a cargo of gypsum from Spain.

The Tobruk government, which no longer controls Tripoli, is recognised by the international community.

Source: Al Jazeera and agencies