The story is told in several versions and they agree on the essentials. During the Roman siege of Jerusalem the zealot factions controlling the city forbade anyone to leave. Johanan ben Zakkai, who had argued for negotiation, arranged with his disciples to be reported dead and carried out of the gates for burial, since a corpse could not remain in the city overnight.
Once outside he was brought to Vespasian, and greeted him as emperor. Vespasian objected that he was a general and not the emperor, and that this was treason; Johanan replied that if he were not emperor he would become one, since only a king could take this city. A messenger then arrived from Rome with news of Nero's death and Vespasian's elevation. In gratitude, or in amusement, Vespasian offered him a request. He asked for Yavneh and its sages, for the survival of a rabbinic family, and for a physician for a colleague.
Whether it happened is not recoverable. The story appears in rabbinic compilations centuries later, it draws on a prophecy motif reported of others in the same period, and it is doing obvious work: it explains, in a single scene, why the tradition's continuity was legitimate and why its founder had not fought. What is not in doubt is the outcome. When Jerusalem fell and the Temple burned, there was a functioning school elsewhere, and a body of scholars in it.