Pirates have attacked an unnamed Greek-owned oil tanker off Nigeria late last week, according to the International Maritime Bureau (IMB).
However, they failed to hijack the ship after the crew hid in a safe room.
The tanker was anchored off Lagos when armed pirates boarded early on Friday, said Noel Choong, head of the IMB's piracy reporting centre in Kuala Lumpur to news agency AFP.
The 23 crew on board managed to lock themselves into a safe room and sent out a distress call that was received by the IMB, which in turn alerted the Nigerian navy and other warships patrolling the area, Choong said.
Choong also said the pirates, likely aiming to steal the ship's cargo, abandoned their plan as they could not enter the safe room and urged crews of other ships off west Africa to be vigilant.
"The area remains risky," he told AFP. "We urge all ships to maintain strict anti-piracy watches.”
At least 21 attacks in the Gulf of Guinea off the west coast of Africa have taken place this year, with four vessels hijacked, according to Choong.
Two seafarers have been killed, two injured and three kidnapped, he said. Nigeria, Africa's largest oil producer, was targeted in 13 out of the 21 attacks, Choong told AFP.