Barry Dullaghan was spotted emerging from a taxi with a blue rucksack by officers carrying out surveillance in Edinburgh's Ferry Road area.
He met with another man and they were walking away together when police approached.
Advocate depute Alastair Carmichael yesterday told the High Court in Edinburgh: "Both the men immediately ran off. The police pursued the accused and stopped and detained him on Ferry Road."
Almost one and half kilos of heroin was found inside the rucksack.
Lord Hardie deferred sentence on Dullaghan until next month for the preparation of a background report.