In the sixth aliyah Bilam goes with Balak and they build seven alters and make sacrifices to G-D. G-D puts a message in Bilam's mouth and he blesses the Jews saying that he cannot curse a people that G-D doesn't curse, that they are a nation dwelling in peace, and not counting itself among the nations. He ends by wishing that his end be like theirs. Balak, who hired him to curse the Jews, complains, and Bilam tells him that he can only say what G-D tells him to say.
Since Bilam didn't curse the Jews yet, Balak now takes Bilam to another place, namely the top of Pisgah, and Balak hopes that Bilam would be able to curse the Jews from there. Rashi says that Balak knew that this was an unfavorable place for the Jews. Rashi says that Balak had this feeling because this was where Moshe Rabeinu would eventually pass away. They build seven altars and make offerings again, then G-D puts further words in Bilam's mouth. According to Rashi Bilam says that G-D has already sworn to bring the Jews to Israel, so they cannot be stopped. He says that there is no iniquity or perverseness in the Jews and the friendship of the King is with them. In fact, some of the phrases of Bilam's prophecies are recited nightly before going to sleep, in the bedtime Shema prayer which protects the Jew at night.