Hanuman's immortality is a combination of multiple boons. First of all, as described in the Kishkindha Kanda of the Ramayana, when Hanuman was a child, he saw the sun and thought it was a fruit, so he flew toward it in an attempt to eat it. When Indra saw Hanuman coming, he threw his Vajra (thunderbolt) to strike him down, in the process injuring Hanuman's left cheekbone. Vayu the wind god, who was Hanuman's father, was furious at his son's injury, so he refused to circulate air in the world anymore (narrated to Hanuman by Jambavan):
Then on observing that you are mutilated, highly infuriated is that scent-wafter Air-god and that tempestuous Air-god has not physically circulated throughout the triad of worlds. When the triad of worlds is being roiled with breathlessness, all the administrative gods of universe are bewildered, and they started to supplicate the Air-god for his grace. Oh, chivalric warrior at war, while the Air-god is being supplicated, oh, dear boy, Brahma gave you a boon decreeing your "indestructibility by any missile." On scrutinising that you are unhurt even after hit by Thunderbolt, oh, ablest Hanuma, the Thousand-eyed Indra kind-heartedly gave you a choicest boon saying that your death occurs only by your own volition.
So Brahma's boon and Indra's boon are two of the causes of his immortality.
The third is described in this excerpt from the Uttara Kanda of the Ramayana. After Rama was told by Yama the god of death that his time on earth is over, Rama prepared to go into the Sarayu river along with his brothers Bharata and Shatrughna (as Lakshmana was already dead). Before he did so, he gave boons to various people, and in particular this was the boon he gave to Hanuman:
[Rama] said to Hanuman: "It is settled that thou shalt live forever, do thou, now observe thy promise. As long as my history shall run current in this world do thou at my command live happily." Being thus addressed by high-souled Raghava Hanuman attained to great delight and said: "As long as the sacred theme shall pass current in this world I shall live here carrying out thy commands."
Finally, you asked whether Rama told Hanuman to stay with the whole Vanara army in the Himalayas. It doesn't look like it; he just gives Jambavan, Mainda, Dvivida, and five other Vanaras (presumably including Nila and Nala) the following boon: "As long as the Kali Yuga exists do ye all live."
EDIT: Here is a fuller description of the boons Hanuman received as a child, from the Uttara Kanda of the Ramayana:
Lord Indra ... spoke the following words: "Because this baby’s jaw was broken by a thunderbolt hurled by my hand, this tiger among monkeys will be known by the name Hanuman. I grant him the supreme and wonderful boon that from this day onwards he will be invulnerable to my thunderbolt."
The venerable sun-god, who dispels darkness, then said: ‘I bestow upon him one percent of my effulgence. When he is able to study the scriptures, I shall give him understanding of the scriptures, by which he will become eloquent. There will be no one like him in understanding of the scriptures."
Varuna granted him the boon that for millions of years he would not die from his noose or from water.
Yama granted him health and invulnerability to his rod of chastisement.
Then Kuvera, the lord of wealth, said: "I am very pleased. I grant him the boon that my mace will not cause his death in combat and that he will not become tired in combat."
Lord Shiva said: “I grant this child the supreme boon that he will be invulnerable to death by me or my weapons."
After glancing at the child, the wise Vishvakarma, the best of technicians, granted him the following boon: "Being invulnerable to the divine weapons made by me, he will be long-lived.’
Lord Brahma said: ‘This child will be long-lived and great. He will be invulnerable to my rod of chastisement and to curses uttered by brahmanas.... This best of monkeys will be able to assume any form he chooses. He will be able to go wherever he wants as fast as he wants." [Emphasis added]