Prophet Yunus tried to convince the people for a long time to worship One God. He even warned them of Allah's punishment if they continued in their sinful ways, but they refused to give up their idol worshipping. They said "O Yunus, do not bother yourself about us. We neither believe in your Lord, nor do we care about any punishment."
At last Prophet Yunus was fed up with these stubborn people. He asked Allah to send His punishment on them and walked out of their town. However, Prophet Yunus had made a mistake because his anger had caused him to leave the people before he had received the command of Allah to do so.
After his departure, the signs of Allah's punishment appeared over Naynivah. A huge cloud came over the whole area and the land was plunged into darkness.
The people at once realised that they were about to be punished for their sins. A wise man from amongst them advised them to ask for Allah's forgiveness at once, before they were all destroyed. All the people, young and old, men and women, came out of their homes and sincerely begged Allah to forgive them. Allah accepted their prayers and withdrew His punishment.
Meanwhile, Prophet Yunus had gone a long distance and had reached the sea. There he saw some people in a boat that was ready to sail. He requested them to allow him to join them. Since he looked like a very respectable person, the passengers of the boat cheerfully welcomed him on board. In the sea, the boat was suddenly caught up in a heavy storm. It was in danger of going under and the captain said that unless they reduced the weight load, they would all drown. It was agreed that one person would have to be thrown overboard. To decide who that person would be, the passengers cast lots. The first time the lot fell to Prophet Yunus, but since he was considered to be a dignified person, the lots were cast again.
When the lot fell to Prophet Yunus the second time, they had no choice but to throw him overboard. At that moment, Prophet Yunus realised his mistake in walking out on his people without waiting for the command of Allah. He knew that his present problems were due to that mistake but he trusted in the Wisdom of Allah and jumped into the stormy sea.
In the meantime, Allah commanded a large fish to swallow Prophet Yunus into its belly. Prophet Yunus suddenly found himself in the stomach of the fish, and he lay there, frightened but unharmed.
The Holy Qur'an says:
Yunus was certainly a Messenger. He abandoned his people and sailed away in a full ship where the people cast lots. Because he lost, he was thrown in the water. The fish swallowed him up and he deserved (all this). Had he not glorified Allah, he would certainly have remained inside the fish until the Day of Resurrection.Prophet Yunus spent several days and nights inside the fish while it swam across the sea. In the darkness of the stomach of the fish Prophet Yunus prayed to Allah to forgive him for his mistake and his prayers were accepted. The Holy Qur'an says:
Zan Nun (Yunus) went away in anger and thought We would never have Power over him, but in darkness he cried, "Lord! You are the only Lord whom I glorify. I have certainly done wrong to myself so forgive me." We answered his prayer and saved him from his grief. Thus do We save the faithful ones.The fish went to the seashore and vomited out Prophet Yunus safely onto the ground. Prophet Yunus's body was badly burnt by the acids inside the fish and Allah caused a plant to grow whose leaves healed Prophet Yunus and whose fruits fed him. Soon Prophet Yunus had regained his health and he was commanded to return to Naynivah.
When he went back he was amazed to see that the people had given up their idol worshipping and were worshipping Allah. His people welcomed him and he spent the rest of his life preaching and leading them on the right path.
(Courtesy of:- Shia Ithna asheri Madressa)