The pills were found at the Tanger Med industrial port complex on the kingdom's northern coast, the DGSN security service said in a statement.
The drugs were "concealed inside a goods container onboard a maritime transport ship" headed from Lebanon to West Africa, it added, without specifying which country.
Searches "led to the discovery and seizure of psychotropic substances hidden inside barrels containing consumer products", according to the DGSN, which said authorities seized "2,018,500 captagon tablets".
An investigation has been launched in the coastal city of Tangier.
Trade of the stimulant has skyrocketed in recent years, mostly originating in Lebanon and Syria, where a multi-billion-dollar industry has made the drug the war-torn country's largest export.
Lebanese authorities have recently ramped up efforts to counter captagon production and trafficking after backlash from conservative Gulf nations.