Navy chief Abdul Aziz Jaafar said the eight pirates, believed to be Indonesians, abandoned the MT Orkim Harmony late Thursday. All 22 crew members are safe except for an Indonesian cook who was shot in the thigh, Abdul Aziz tweeted.
The ship is sailing to Malaysia's northern Kuantan port, escorted by a naval ship, he said.
Abdul Aziz said Vietnam had arrested eight men on a life raft who claimed to be from a fishing boat that sank, and that Malaysian authorities are investigating whether they are the hijackers.
The tanker, carrying 7.5 million liters (2 million gallons) of gasoline worth 21 million ringgit ($5.7 million), was headed to Kuantan when communications were lost June 11. The crew consists of 16 Malaysians, five Indonesians and a Myanmar national.
The Malaysian Maritime Enforcement Agency said earlier that the ship was located in waters off southern Vietnam late Wednesday and had been repainted black from blue. Abdul Aziz also tweeted pictures of the tanker, showing some letters of the name of the ship painted over to give it a new name, "Kim Harmon."
Abdul Aziz said the pirates had warned the navy ship tailing the tanker to stay at a distance or they would harm the crew. He said the captain of the tanker waited for five hours to inform the navy ship after the pirates fled because they took his family's home address and threatened to harm them.
He said the pirates were armed with pistols and machetes and spoke with Indonesian accents.
The maritime agency said the hijacking was believed to be the work of a syndicate targeting vessels for their cargos of fuel. It said this was the fifth theft in waters off southern Malaysia this year.
It was the second tanker hijacked this month. Another Malaysian tanker carrying diesel fuel was hijacked June 4 in the same area and was released after its fuel was siphoned off.
Maritime officials have said it is more difficult to steal gasoline because it is highly flammable and requires special safety equipment.
The International Maritime Bureau says attacks against small tankers off Southeast Asia's coasts have been rising since last year.
Pirates have been particularly active near Indonesia's Bintan island and in the South China Sea, where 11 vessels were hijacked last year, the bureau said.