Withwinar's post contains a link to an AI modification guide. It focuses on the campaign_ai_db, but dose get into diplomacy some. I think Kilic actually meant the descr_faction_standing.txt which deals more with relations where the descr_diplomacy.xml actually involves the actual diplomacy function and not relations directly.
Easiest way to achieve what you want would be to increase the effect religion has on determining who to attack in the descr_campaign_ai_db.xml. You may also want to increase the effects of faction standing, but that's getting into pretty drastic modding. IMO youre best bet would be to take a pre-existing AI mod, such as XAI and just increase the religion effects, unless you intend to do a complete AI mod.
You could put a trigger in descr_faction_standing.txt specific to Portugal and Spain, but that would limit the AI's options and allow easier player exploits.