Basic Rule
Divine casters have spells available in a manner similar to wizards, but granted by deities rather than learned from writings.

Domain Spells and Spontaneous Casting
This rule does not affect domain spells or spontaneous casting. Any spell prepared or cast as a domain spell, or cast spontaneously, need not have been gifted using these rules and uses the rules already in the books or SRD.

Initial Spells Known
A cleric begins play with gifted with all 0-level cleric spells plus three 1st-level spells of your choice. For each point of Wisdom bonus the cleric has, the cleric has recieved one additional 1st-level spell of your choice. At each new cleric level, he recieves two new spells of any spell level or levels that he can cast (based on her new cleric level).

Being Gifted with Additional Spells
Clerics can become gifted with new spells through several methods.

Spells Gifted at a New Level
Each time a character attains a new cleric level, he is given two spells of her. The two free spells must be of spell levels he can cast.

Spells Gifted Due to Quests from Deities
A cleric will also be gifted with a new spell whenever he accomplishes a quest set by a deity.
While a deity who really, really, really, wants something done might provide a quest unasked, quests are normally granted at the request of the cleric. If a cleric asks for a quest while preparing spells, the deity will cast geas/quest on the cleric a caster level of at least 50.
When and if the quest has been successfully completed, the cleric must make a Knowledge (religion) check (DC 2 * number of cleric spells of that level the cleric already knows).
If the check succeeds, the cleric receives a spell of her choice from the cleric list.
If the check fails, the cleric receives a spell of the deity’s choice from the cleric list.
If the cleric is not devoted to a particular deity, the quests and spells are provided by a philosophically allied deity.

Spells Gifted Due Exemplary Behavior
A cleric might also be offered a new spell if his support for the deities causes are above and beyond what is normally expected of divine casters.
In such a case, the cleric will be offered a spell of the deity’s choice from the cleric list. The cleric may turn down this offer.

Independent Research
A cleric still can research a spell independently, duplicating an existing spell or creating an entirely new one.

Other Divine Casters
Druids are granted spells from the druid list, and do not have domain spells. They otherwise receive quests and spells as clerics.
A paladin or ranger who reaches 4th level gains two first level spells from the appropriate list. Additional spells from that list are granted in the same manner as clerics.