Rare spells cannot be chosen for free from character level up.
Any spell that is not in the Player's Handbook (PH) is automatically considered a rare spell. (you may discuss with DM)
In addition the following spells from the PH are considered rare:
5th level: Teleportation Circle
6th level: Arcane Gate
7th level: Plane Shift. Teleport
8th level: Demiplane
9th level: Astral Projection, Gate, Time Stop, Wish