The story of Yongjia's brief first encounter with Huineng is recorded in the Transmission of the Lamp. The tale tells of one of Huineng's students encountering Yongjia, and through conversation finding that his opinions were very similar to those of the great Zen teachers of the time. When asked who his teacher was, Yongjia replies that he had none, but rather he had attained his understanding from sutras, especially the Vimalakirti Sutra. Huineng's student then explains that one's understanding should be confirmed, to which Yongjia requests that he testify to his enlightenment. The student states that his own personal opinion is meaningless, and he should instead visit Huineng in Caoxi.
Arriving at the temple, Yongjia walks around Huineng three times and then stands staring at him. Huineng comments on his lack of formality, to which Yongjia responds, "Since the question of incessant rebirth is a momentous one and death may come at any moment, I have no time to waste on ceremony, and wish you to give me a quick answer to this problem". Huineng suggests he "embody birthlessness" in order to overcome impermanence. Yongjia immediately displays understanding of this, but then readies himself to leave. Huineng asks if he is not leaving too quickly. Yongjia then says there is no such thing as "quickly", for motion does not truly exist. Huineng asks why this should be the case, to which he responds that any distinction about quickness or slowness is an artificial construct. Huineng then exclaims that his interlocutor now truly understands the concept of birthlessness, but Yongjia cleverly asks if a mere concept, another form of artificial distinction, can really have a meaning. Huineng asks, "Who makes a distinction about whether there is a meaning or not. Yongjia responds, "Distinctions are meaningless!", and Huineng cries, "Excellent! Excellent! Now, just stay here a single night!" This is so that Huineng can officially confirm his enlightenment. And thus, Yongjia is known as "The Overnight Guest" because he proved his enlightenment to Huineng in one night.
Despite this story, in the oldest version of the Platform Sutra found among the Dunhuang manuscripts, which dates to about 850 CE, Yongjia is not mentioned as a student of Huineng.