Narrated Ubai bin Ka'b:

The Prophet (s.a.a.w.) said, "Once the Prophet Moses (peace be on him) stood up and addressed Bani Israel. He was asked, "Who is the most learned man amongst the people. He said, "I am the most learned." Allah admonished Moses as he did not attribute absolute knowledge to Him (Allah). So Allah inspired to him "At the junction of the two seas there is a slave amongst my slaves who is more learned than you." Moses said, "O my Lord! How can I meet him?" Allah said: Take a fish in a large basket (and proceed) and you will find him at the place where you will lose the fish. So Moses set out along with his (servant) boy, Yusha' bin Nuin and carried a fish in a large basket till they reached a rock, where they laid their heads (i.e. lay down) and slept. " (based on Sahih Bukhari, Volume 1, Book 3, Number 124)

The story is mentioned in the Holy Quran as follows:

018.060  Behold, Moses said to his attendant, "I will not give up until I reach the
junction of the two seas or (until) I spend years and years in travel."

018.061  But when they reached the Junction, they forgot (about) their Fish, which
took its course through the sea (straight) as in a tunnel.

018.062  When they had passed on (some distance), Moses said to his attendant:
"Bring us our early meal; truly we have suffered much fatigue at this (stage of) our
journey."

018.063  He replied: "Sawest thou (what happened) when we betook ourselves to the rock? I did indeed forget (about) the Fish: none but Satan made me forget to tell (you) about it: it took its course through the sea in a marvellous way!"

018.064  Moses said: "That was what we were seeking after:" So they went back on
their footsteps, following (the path they had come).

018.065  So they found one of Our servants, on whom We had bestowed Mercy from
Ourselves and whom We had taught knowledge from Our own Presence.

018.066  Moses said to him: "May I follow thee, on the footing that thou teach me
something of the (Higher) Truth which thou hast been taught?"

018.067  (The other) said: "Verily thou wilt not be able to have patience with me!"

018.068  "And how canst thou have patience about things about which thy
understanding is not complete?"

018.069  Moses said: "Thou wilt find me, if God so will, (truly) patient: nor shall I
disobey thee in aught."

018.070  The other said: "If then thou wouldst follow me, ask me no questions about
anything until I myself speak to thee concerning it."

018.071  So they both proceeded: until, when they were in the boat, he scuttled it.
Said Moses: "Hast thou scuttled it in order to drown those in it? Truly a strange thing hast thou done!"

018.072  He answered: "Did I not tell thee that thou canst have no patience with me?"

018.073  Moses said: "Rebuke me not for forgetting, nor grieve me by raising
difficulties in my case."

018.074  Then they proceeded: until, when they met a young man, he slew him.
Moses said: "Hast thou slain an innocent person who had slain none? Truly a foul
(unheard of) thing hast thou done!"

018.075  He answered: "Did I not tell thee that thou canst have no patience with me?"

018.076  (Moses) said: "If ever I ask thee about anything after this, keep me not in thy company: then wouldst thou have received (full) excuse from my side."

018.077  Then they proceeded: until, when they came to the inhabitants of a town,
they asked them for food, but they refused them hospitality. They found there a wall
on the point of falling down, but he set it up straight. (Moses) said: "If thou hadst
wished, surely thou couldst have exacted some recompense for it!"

018.078  He answered: "This is the parting between me and thee: now will I tell thee
the interpretation of (those things) over which thou wast unable to hold patience.

018.079  "As for the boat, it belonged to certain men in dire want: they plied on the
water: I but wished to render it unserviceable, for there was after them a certain king who seized on every boat by force.

018.080  "As for the youth, his parents were people of Faith, and we feared that he
would grieve them by obstinate rebellion and ingratitude (to God and man).

018.081  "So we desired that their Lord would give them in exchange (a son) better in purity (of conduct) and closer in affection.

018.082  "As for the wall, it belonged to two youths, orphans, in the Town; there was, beneath it, a buried treasure, to which they were entitled: their father had been a righteous man: So thy Lord desired that they should attain their age of full strength and get out their treasure - a mercy (and favour) from thy Lord. I did it not of my own accord. Such is the interpretation of (those things) over which thou wast unable to hold patience."

The Holy Quran has the events mentioned in Chapter 18 as follows:

018.060  Behold, Moses said to his attendant, "I will not give up until I reach the
junction of the two seas or (until) I spend years and years in travel."

018.061  But when they reached the Junction, they forgot (about) their Fish, which
took its course through the sea (straight) as in a tunnel.

018.062  When they had passed on (some distance), Moses said to his attendant:
"Bring us our early meal; truly we have suffered much fatigue at this (stage of) our
journey."

018.063  He replied: "Sawest thou (what happened) when we betook ourselves to the
rock? I did indeed forget (about) the Fish: none but Satan made me forget to tell (you)
about it: it took its course through the sea in a marvellous way!"

018.064  Moses said: "That was what we were seeking after:" So they went back on
their footsteps, following (the path they had come).

018.065  So they found one of Our servants, on whom We had bestowed Mercy from
Ourselves and whom We had taught knowledge from Our own Presence.

018.066  Moses said to him: "May I follow thee, on the footing that thou teach me
something of the (Higher) Truth which thou hast been taught?"

018.067  (The other) said: "Verily thou wilt not be able to have patience with me!"

018.068  "And how canst thou have patience about things about which thy
understanding is not complete?"

018.069  Moses said: "Thou wilt find me, if God so will, (truly) patient: nor shall I
disobey thee in aught."

018.070  The other said: "If then thou wouldst follow me, ask me no questions about
anything until I myself speak to thee concerning it."

018.071  So they both proceeded: until, when they were in the boat, he scuttled it.
Said Moses: "Hast thou scuttled it in order to drown those in it? Truly a strange thing
hast thou done!"

018.072  He answered: "Did I not tell thee that thou canst have no patience with me?"

018.073  Moses said: "Rebuke me not for forgetting, nor grieve me by raising
difficulties in my case."

018.074  Then they proceeded: until, when they met a young man, he slew him.
Moses said: "Hast thou slain an innocent person who had slain none? Truly a foul
(unheard of) thing hast thou done!"

018.075  He answered: "Did I not tell thee that thou canst have no patience with me?"

018.076  (Moses) said: "If ever I ask thee about anything after this, keep me not in thy
company: then wouldst thou have received (full) excuse from my side."

018.077  Then they proceeded: until, when they came to the inhabitants of a town,
they asked them for food, but they refused them hospitality. They found there a wall
on the point of falling down, but he set it up straight. (Moses) said: "If thou hadst
wished, surely thou couldst have exacted some recompense for it!"

018.078  He answered: "This is the parting between me and thee: now will I tell thee
the interpretation of (those things) over which thou wast unable to hold patience.

018.079  "As for the boat, it belonged to certain men in dire want: they plied on the
water: I but wished to render it unserviceable, for there was after them a certain king
who seized on every boat by force.

018.080  "As for the youth, his parents were people of Faith, and we feared that he
would grieve them by obstinate rebellion and ingratitude (to God and man).

018.081  "So we desired that their Lord would give them in exchange (a son) better in
purity (of conduct) and closer in affection.

018.082  "As for the wall, it belonged to two youths, orphans, in the Town; there was,
beneath it, a buried treasure, to which they were entitled: their father had been a
righteous man: So thy Lord desired that they should attain their age of full strength
and get out their treasure - a mercy (and favour) from thy Lord. I did it not of my own
accord. Such is the interpretation of (those things) over which thou wast unable to
hold patience."