TL;DR: It was hinted at in the movies, and then explained in detail later in EU books (more specifically, Rebel Dawn - the 3rd book in the Han Solo trilogy).
In A New Hope, Greedo, while infamously chatting with Solo before Han shot him first he tried to shoot Han, says:
Greedo: Jabba's through with you! He has no use for smugglers who drop their shipments at the first sign of an Imperial cruiser.
Han Solo: Even I get boarded sometimes. Do you think I had a choice?
It doesn't provide any more details. (There's a chance that the Special Edition Han + Jabba scene has more info, but I will just pretend the Special Edition never happened)
In Rebel Dawn, the exact back-story of this is shown.
Han is (near the end of the book) one of Jabba's best (and favorite) pilots.
Jabba tells him to deliver some Glitterstim.
In the process, during the Kessel run, he is ambushed by some Imperials and forced to dump the contraband in the Maw when he discovers that boarding is imminent, when - after a record-setting run that set the famous "12 parsecs" record - he gets OUT of the black hole region only to find a second Imperial patrol waiting for him.
"Chewie, we ain't gonna be able to outrun these Imps," Han said. "And we're out-gunned. But we've lost that guy on our tail, at least for the moment. I think if we can get far enough ahead, we should go ahead and dump the load just inside the Pit..."
He hopes to pick up the drugs later, but when he finally has a chance to return, there's no trace of the shipment.
The extra candy is that this specific backstory ALSO includes the infamous "12 Parsecs Kessel Run" retcon!
Now the last Imperial ship was falling behind... and the Falcon was nearly out of the Maw.
... Moments later they were safe in hyperspace. Han slumped back in his seat. ... As he sagged in his seat, Han noticed something.
... Hans eyes narrowed. "Hey, this is weird," he said. "It says we actually shortened the distance we traveled, not just the time. Less than twelve parsecs!"
Chewie growled skeptically and rapped on the distance gauge with hairy knuckles, commenting that Han's wild piloting must have caused a short and the gauge was off.
"... But I did do it in under twelve parsecs ...." he thought stubbornly.