Somali hijackers released a Greek-owned tanker and its 28-member crew in the Indian Ocean on Monday, after collecting a large ransom—and finding themselves in a gun battle with another band of pirates seeking to claim a share.

The Greek-owned tanker Maran Centaurus, laden with two million barrels of Saudi Arabian crude oil valued at about $156 million, had been held by the pirates since late November.

Two...