That Bilam was a prophet is stated in a number of sources, such as Bava Batra 15b:
"... Seven prophets prophesied to the nations of the world, and they are: Balaam and his father Beor..."
Other sources include Bamidbar Rabbah 14:20, Sifrei Devarim 357:40 and more.
But he was also a magician or diviner. The Talmud in Sanhedrin 106a explains:
"It is stated: “And Balaam, son of Beor, the diviner, did the children of Israel slay with the sword among the rest of their slain” (Joshua 13:22). The Gemara asks: Was he a diviner? He is a prophet. Rabbi Yoḥanan says: Initially he was a prophet, but ultimately, he lost his capacity for prophecy and remained merely a diviner. Rav Pappa says that this is in accordance with the adage that people say: This woman was descended from princes and rulers, and was licentious with carpenters."
Me'am Loez on Bamidbar 22:5 writes (my translation):
"...and at the time Balak came to know Bilam as a soothsayer and great diviner, for at the time he prophecised to him that he would become king.
And some say that for this reason that city was called P'torah, because Bilam at first solved dreams (poter), and afterwards became a diviner, and after that rose in level in that the holy spirit rested upon him and he would prophecise things of prophecy..."
Later, Me'am Loez writes:
"And at first Balak and Bilam attempted to work different sorts of enchantments against Yisrael. And upon seeing that these enchaments had no power against Yisrael, they went to curse..."
So it seems that Bilam was both a prophet, a diviner and a magician. A prophet recieves his abilities from Hashem. A diviner, as explained by Me'am Loez, doesn't receive his abilities from Hashem. And magic, as outlined in the portion of the Me'am Loez that I didn't quote, comes from dark forces of impurity. Bilam attempted to use all of his abilities against Yisrael, and failed with all of them, save for his eventual advice to cause Yisrael to sin with Ba'al Pe'or.