Nandi cursed Ravana that monkeys would destroy him.
The episode takes place near Mount Kailash, Shiva’s sacred abode. After conquering territories and taking Kubera’s aerial chariot, Ravana found that the Pushpaka Vimana could not pass over the mountain. Nandi, Shiva’s attendant and bull vehicle, stopped him and explained that Shiva and Parvati occupied the area.
Ravana mocked Nandi’s appearance, sometimes described in the tradition as comparing him to a monkey. In anger, Nandi declared that forest-dwelling monkeys would bring about Ravana’s destruction. Ravana then tried to lift Mount Kailash, but Shiva pressed the mountain down with his toe and trapped him beneath it. Ravana eventually praised Shiva and was released.
The curse is later understood as foreshadowing the Ramayana war. Hanuman, a vanara, crossed the sea, found Sita, and burned much of Lanka; Rama’s vanara allies then helped defeat Ravana. Thus the story links a Shaiva legend involving Kailash with the Ramayana’s account of Ravana’s downfall.
A common mix-up is to credit the curse to Agastya or another famous sage. In this particular legend, Nandi is Shiva’s guardian and attendant rather than a human rishi, and his insult-driven prophecy is the canonical answer in the relevant tradition.