Yunus (peace be upon him), also called Dhun-Nun (the companion of the fish), was sent to a people numbering many, but when they rejected him, he departed in anger, assuming Allah would not constrain him (21:87, 37:139-140). He boarded a laden ship, lots were cast, and he was among those thrown overboard, whereupon a great fish swallowed him (37:141-142).
In the darkness of the fish's belly, Yunus called out, "There is no deity except You; glory be to You. Indeed I have been among the wrongdoers" (21:87). Allah states that had he not been among those who glorify Allah, he would have remained in the fish's belly until the Day of Resurrection (37:143-144).
Allah answered his call, delivered him from distress, and cast him onto the open shore while he was ill, causing a gourd plant to grow over him (21:88, 37:145-146). Allah affirms, "And thus do We save the believers" (21:88).
Remarkably, the people of Yunus believed when they saw the approaching punishment, and Allah removed the disgrace of chastisement from them and let them enjoy life for a time, a unique instance where a whole community's faith averted destruction (10:98, 37:147-148). The Prophet Muhammad ﷺ was told not to be like the companion of the fish who called out while distressed (68:48).