After Vali defeated the buffalo-asura Dundhubi, Dundhubi's son, Mayavi, decided to avenge his father. "I will kill you, Vali!" Mayavi roared as he came crashing through the forest.
Vali and Mayavi fought one another there in the forest, and then Mayavi fled into a cave.
Before following Mayavi into the cave, Vali commanded his brother Sugriva to keep watch. "If I fail and Mayavi emerges from the cave, you must kill him."
No one emerged from the cave.
Thinking Vali was dead, Sugriva sealed up the cave and declared himself king.
But Vali was not dead.
Inspired by: Sita: An Illustrated Retelling of the Ramayana by Devdutt Pattanaik
Notes: This story is on p. 154 of the book. In Valmiki's Ramayana, this is the Kishkindha Kanda (Book 4), sarga 11.