Hanuman is Chiranjeevi - one who lives forever. Thus even as various eras passed by Hanuman was ever-present. He was also told that Lord Sriram would reappear as Lord Krishna at a future time. Thus Hanuman appears in the Mahabharata at two junctures - once to quell the pride of Bheema and the second time to see Lord Krishna.
Bheema was the brother of Hanuman in the sense that Bheema was also born as a result of a boon from Vayudeva. Once when the Pandava's were resting in the forest, a heavenly flower by name Sugandikapushpa floated through the air into the lap of Draupadi. Totally enchanted by its beauty and fragrance she asked Bheema to get some more flowers for her. Thus Bheema went in the direction in which the flower had flown. He found it in a lake belonging to Gandharvas (the court musicians of Lord Indra), after a fierce battle he was able to obtain the flowers. Thus triumphantly, Bheema headed back, proud of his strength. On his way back he found an aged monkey blocking his path, since it was the custom not to cross a living person, Bheema, his thoughts still swollen with pride, called out loud to the monkey to clear the path. The feeble monkey told him that it was too tired, it requested the powerful warrior to move it's tail aside. An arrogant Bheema could not budge the tail though he tried with all his might. Realizing his folly he apologized to the monkey. Seeing his arrogance quelled, the monkey returned to its original form; it was none other than Lord Hanuman who had come to subdue the pride of his brother.
Hanuman told Bheema, after the above-mentioned incident that he would appear on the flag of Arjuna's chariot. But I will relate the second story because it is here that Hanuman actually meets Lord Krishna.
In an argument between Hanuman and Arjuna, Arjuna claimed that he could reconstruct the bridge built by the Vanar army during Lord Sriram's war with Ravana using his archery skills. Hanuman laid the challenge that if Arjuna could build a bridge that could withstand his weight, let alone an army's, then he would be on the flag of Arjuna's chariot in the war. But should Arjuna fail it was decided that Arjuna would give up his life by entering a pyre. Arjuna built a bridge in a jiffy and when Hanuman stepped on it the whole bridge collapsed, Arjuna, immensely disappointed decided to end his life. At this moment Lord Krishna appeared and asked Arjuna to build the bridge again. After Arjuna rebuilt the bridge, Lord Krishna touched the bridge and asked Hanuman to walk over it. Despite his best efforts Hanuman could not break the bridge; at this instant Hanuman saw Lord Sriram in Krishna and was overcome with emotion. He promised to aid Arjuna in the war by being on the flag of Arjuna's chariot, thus stabilising and protecting it.
Hanumanji’s flag signifies sense control and mind control that gives victory to the higher nature over the lower nature.
Arjuna's Chariot bursts into flames:
At the conclusion of the war (Shalya Parva), as soon as Lord Krishna and Lord Hanuman exit Arjuna’s chariot, the chariot, along with the horses, instantly catches flames.
The Mahabharata, Book 9: Shalya Parva, chapter 62:
Keshava, addressed the wielder of gandiva, saying, "Take down thy gandiva as also the two inexhaustible quivers. I shall dismount after thee, O best of the Bharatas! Get thee down, for this is for thy good, O sinless one!"
Pandu's brave son Dhananjaya did as he was directed. The intelligent Krishna, abandoning the reins of the steeds, then dismounted from the car of Dhananjaya. After the high-souled Lord of all creatures had dismounted from that car, the celestial Ape that topped the mantle of Arjuna's vehicle, disappeared there and then. The top of the vehicle, which had before been burnt by Drona and Karna with their celestial weapons, quickly blazed forth to ashes, O king, without any visible fire having been in sight. Indeed, the car of Dhananjaya, with its quick pairs of steeds, yoke, and shaft, fell down, reduced to ashes.
Beholding the vehicle thus reduced to ashes, O lord, the sons of Pandu became filled with wonder, and Arjuna, O king, having saluted Krishna and bowed unto him, said these words, with joined hands and in an affectionate voice, 'O Govinda, O divine one, for what reason hath this car been consumed by fire? What is this highly wonderful incident that has happened before our eyes! O thou of mighty arms, if thou thinkest that I can listen to it without harm, then tell me everything.'
Vasudeva said, 'That car, O Arjuna, had before been consumed by diverse kinds of weapons. It was because I had sat upon it during battle that it did not fall into pieces, O scorcher of foes! Previously consumed by the energy of brahmastra, it has been reduced to ashes upon my abandoning it after attainment by thee of thy objects!'