Avere is used in most cases. Transitive verbs (verbs which have a direct object) always use avere.
Some verbs can be used both transitively (with a direct object) and intransitively (without a direct object). When used transitively, in compound tenses they are conjugated with the auxiliary avere. When used intransitively, in compound tenses they take the auxiliary essere. For example, lei è affogata (she drowned); but lei ha affogato i suoi dispiaceri (she drowned her sorrows).
The general rule of exceptions is that essere is used with verbs of:
- Movement (andare, arrivare, entrare, partire, ritornare, salire, scappare, tornare, uscire, venire, etc.); but not camminare, passeggiare, or viaggiare, which use the auxiliary avere ;
- State (essere, esistere, rimanere, restare, sembrare, stare, vivere, etc.);
- Change (apparire, cambiare, crescere, diventare, nascere, morire, svanire, etc.);
- Reflexive verbs (alzarsi, lavarsi, vestirsi, etc.)
- Impersonal verbs – used in the third person (abbondare, abbuiare, accadere, bastare, costare, dipendere, durare, mancare, occorrere, piacere, succedere, etc. )
The modal verbs dovere, potere and volere take the auxiliary (avere or essere) of the verb that follows them.
When the perfect tense is formed with essere, the past participle behaves like an adjective – it has to agree in gender and number with the subject of the verb. When the perfect tense is formed with avere, the past participle does not change.
Note also that some verbs can be used either reflexively (i.e. when the action is directed back on the subject) or non-reflexively (for example, lavarsi – to have a wash, vs lavare – to wash sth or sb). When used reflexively, they take the auxiliary essere.
See longer list of verbs that take the auxiliary essere.