Ifeanyi Johnpaul Aguonu, 38, was also slapped with 10 strokes of the cane for the offence of bringing the drugs into the country in March 2011.
High Court Justice Abdul Alim Abdullah expressed concern that many Nigerians had entered Malaysia with drugs without any fear of the law.
"Our country has a strict rule when it comes to drugs, that the law provides a death penalty for drug trafficking. If you are convicted of a capital offence here, you could have been hung from the neck until you die," the judge said before sentencing Aguonu.