The detailed story can be found in The Mahabharata, Book 3: Vana Parva: Aranyaka Parva: Section X.
Maitreya on a pilgrimage to the different shrines, saw Yudhishthira in the woods of Kamyaka.
Later he visited Duryodhan and advised not to quarrel with the Pandavas.
But admonished by Maitreya,
Duryodhana began to slap his thigh resembling the trunk of the elephant, and smilingly began to scratch the ground with his foot. And the wicked wretch spake not a word, but hung down his head.
By this Maitreya became angry and he set his mind upon cursing Duryodhana! And then, with eyes red in anger, Maitreya, touching water cursed Duryodhana as follows:
Since, slighting me thou declinest to act according to my words, thou shalt speedily reap the fruit of this thy insolence! In the great war which shall spring out of the wrongs perpetrated by thee, the mighty Bhima shall smash that thigh of thine with a stroke of his mace!