Sarmud Akhtar, aged 20, was chased by officers after he fled from a car in Northampton before trying to dispose of the drugs when he was cornered in an alleyway.
At Northampton Crown Court he was sent to prison for 27 months, even though prosecuto
rs conceded the drugs he was carrying belonged to another man.
The court heard Akhtar, a student at The University of Northampton, was given the package containing 50g of cocaine while a passenger in a BMW being driven by Andrew Williamson, 24.
Mr Williamson was "known to police" and officers had been following his car until it stopped in Wellingborough Road, Abington, and Akhtar got out.
After a short chase he was caught in an alley near Roseholme Road where he dropped the package.
Lucy Fairclough, prosecuting, said: "Mr Akhtar knew the package he was given was drugs. When he left the car and was running from the police he knew it was drugs.
"Until he dropped the package on the floor, he intended to hand those drugs back to Mr Williamson."
Despite protesting the cocaine did not belong to him, Akhtar, of Boughton Green Road, Kingsthorpe, admitted possessing the class A drug with intent to supply.
Mark Love, mitigating, said his client had never been in trouble with the police before and made "the wrong decision" when he decided to run from police.
He said: "He found himself in a world of which he had no experience."
Mr Love urged Judge Richard Bray to spare Akhtar a prison sentence, but although the judge accepted the drugs were not Akhtar's, he said the severity of the crime made jail inevitable.
"This remains a very serious offence," he said. "I would be failing in my duty if I did not pass a custodial sentence of some length."