All spells have a rarity rating: Common, Rare, or Unique.
Common spells are generally well-known, at least in theory, to all spellcasters. All spells in the Pathfinder Core Rulebook are common.
Rare spells reflect effects that are not normally seen, divine powers not normally granted, or have highly specialized effects. In general, most spellcasters are unfamiliar with a specific rare spell until it is actually seen in use (or described in detail by a witness). Unless noted elsewhere, all spells from the Advanced Player’s Guide are rare.
Unique spells reflect the fruits of independent spell research, whether arcane or divine. Such spells are generally known only to the individual creator, or to a small cabal of individuals who have learned the spell directly from the creator. Once a unique spell is learned beyond a small cabal, it is considered rare instead. Unless noted elsewhere, any spell published in any other official Paizo supplement (other than the Core Rulebook or APG) should be considered unique.
Spellcraft or knowledge checks to identify common spells or their effects have normal DC. The DC to identify an umfamiliar rare spell is 5 higher, and that of a unique spell is 10 higher. Dispelling or counterspelling rare or unique spells is otherwise normal.
Spell rarity and gaining new spells:
A wizard can add a rare or unique spell to his or her spellbook normally by finding the spell in another wizard’s spellbook or on a spell scroll. Any arcane caster can learn a rare or unique spell through independent spell research. See the “Research and Designing Spells” section of the Pathfinder Gamemastery Guide for spell research rules, or view them online at the at the Pathfinder SRD
When an arcane spellcaster gains a level, he or she may freely select from common spells as his or her free new spells.
When leveling up, an arcane spellcaster can can learn a rare or unique spell for free by finding it in a spellbook, arcane spell scroll, or directly from another arcane caster.
If a direct source is not available, any arcane caster can learn rare spells when leveling up for free by finding them in an arcane library. Finding a rare spell in this manner doesn’t cost money (other than any fee to access the library), but takes two days per spell level and requires a Spellcraft check (DC 15 + double the spell’s level). If the check fails, the caster may keep trying and make another check every two days, but three failures in a row means that particular spell cannot be learned from that particular library. Unique spells cannot be learned in this manner.
Divine spellcasters are assumed to be unfamiliar with rare or unique spells, and simply do not know that the gods can grant them.
A divine spellcaster who already knows a rare or unique spell can share the knowledge with other divine spellcasters of the same faith. Such sharing takes one day regardless of spell level. Rare or unique spells can also be learned from direct reference in holy writings, a spell scroll of the spell, or by a divine magic item that has the spell effect. Learning the spell from a scroll uses up the spell from the scroll.
If a direct source is not available, a divine spellcaster can research a specific rare divine spell by studying holy writing or religious history, or by conferring with other priests. This does not cost money, but takes two days per spell level, and requires access to a temple library and/or another priest who has heard stories of such an effect. Such research requires two days per spell level and requires a knowledge (religion) check (DC 15 + double the spell’s level). If the check fails, the caster can keep trying, making another check every two days. Three failures indicates that this particular temple has no records or knowledge of this particular spell. Unique spells cannot be learned in this manner.
A divine spellcaster can research a rare or unique spell via independent spell research, much as an arcane spellcaster can (see above).
Once a divine spellcaster has been granted a specific rare or unique spell, he or she may prepare it normally afterward.