Srimad Bhagvata Mahapurana: Book 1: Chapter 9: Verses 17-31
Therefore, knowing it for certain that all these events depend on the will of Providence, O chief of the Bharatas, follow His will, 0 ruler of men, and protect the helpless people as you are their sole monarch. "Sri Krsna is God Himself. He is no other than the Prime Person, Lord Narayana. Deluding the world by His Maya, He lives incognito among the Vrsnis (a branch of the Yadus). No one else than Lord Siva, the celestial sage Narada and Lord Kapila Himself, O Yudhisthira, know the most hidden glory of Sri Krsna, whom you think to be your cousin (maternal uncle's son), beloved friend and greatest well-wisher and whom out of affection you made your counsellor, envoy and charioteer ! In Him,who is the Soul of the universe, who looks upon all with the same eye, is one without a second and is free from egotism and blemishless, there can be no sense of diversity in regard to these divergent functions on any account. Yet, O king, look at His compassion for those who are exclusively devoted to Him, in that Sri Krsna has appeared in person before me at this hour, when I am about to give up the ghost. A Yogi (mystic) who casts off his body with his thought fixed on Him through devotion and chanting His Name with his tongue is rid of all hankerings and released from the bondage of actions. May that Lord, who is adorable even for gods and possessed of four arms, whose lotus-like countenance beams with gracious smiles and reddish eyes and who appears to others only in their meditation stay on here till I shuffle off this body."
Suta continued: Hearing this, Yudhisthira asked Bhisma even as he lay on his cage-like bed of arrows questions concerning a variety of Dharmas (sacred obligations or courses of conduct) in the presence of the Rsis. Thereupon Bhisma, who had realized the Truth, discoursed upon, one by one, the various Dharmas (duties) determined by the innate disposition of men and apportioned with due regard to their Varna (social grade) and Asrama (stage in life) and the twofold Dharmas (the Dharmas involving worldly activity-Pravrtti, and those marked by withdrawal from such activity-Nivrtti) severally recommended for those endowed with dispassion and those who are full of worldly attachment, the Dharmas relating to charitable gifts, the duties obligatory on monarchs, the courses of conduct which are conducive to liberation, the duties of women and the courses of conduct that are intended to propitiate the Lord, both briefly and in detail. He also explained, O Saunaka, the four ends of human pursuit, viz., Dharma (religious merit), Artha (worldly riches), Kama (sensuous enjoyment) and Moksa (final beatitude or liberation) as well as the means to them in their true perspective with the help of many illustrative anecdotes and stories. While he was thus discoursing on Dharma, there arrived the time when the sun changes its course towards the north--a time which is coveted by Yogis (mystics) who drop their body according to their pleasure. Thereupon Bhisma (who had led on the battle-field thousands of warriors) wound up his speech and exclusively fixed his mind, which was absolutely free from worldly attachment, as well as his eyes, which knew no winking, on Sri Krsna, the Prime Person, who was present before him in His four-armed form, clad in shining yellow robes. The last traces of sin (if any) left in him were obliterated by his concentrated thought on the Most Holy and the pain which he felt on account of the weapons (arrows piercing his body) quickly disappeared at a mere glance of the Lord. Now, while casting off his body, he stopped all the activities and wanderings of his senses and extolled Lord Janardana (Sri Krsna).