MOGADISHU, Somalia  A Saudi-owned supertanker held by pirates off the coast of Somalia for two months has been released for a ransom of $3 million, according to one of the pirates and residents of Xarardheere, a pirate town on the Somali coast near where the tanker was being held.

The tanker, about the length of an American Nimitz-class aircraft carrier, is the largest ship known to have been seized by pirates, and it was fully loaded with two million barrels of oil.

The pirates were due to leave the ship after they received the money, paid by the ship’s owners, on Friday, according to the pirates and residents, who later said the ship had moved away from the coast where it had been anchored since November.

News agencies had reported that the pirates originally asked for $25 million for the oil tanker, the Sirius Star, but a pirate in Xarardheere who gave his name as Jama said, “They have agreed on $3 million.” He said he had spoken to pirates who had gone to the ship for the payment.