Last minute decision
The Spanish delegation and reporters travelling with them were not informed about the ban until Sunday night, but tried to enter the university anyway on Monday.
A justice ministry spokeswoman in Madrid said: "Yesterday, at the last minute, we were told women couldn't enter the university.
He cancelled because the none of the women were allowed to be there."
She said a written copy was given to students instead. Graduates of Al-Imam Muhammad Ibn Saud university work in the government, mosques, courts and in the religious police force which patrols all Saudi cities and towns to enforce Islam-oriented public order.
Last March, Britain's Prince Charles became the first non-Muslim foreign dignitary to visit the university.
The lecture was to have closed a two-day visit by Lopez Aguilar, who is stepping down from the justice post to run for office in his native Canary Islands region.