By Magdi Abdelhadi
BBC Arab affairs analyst
The head of one of the world's most prestigious centres of Islamic learning has upheld the right of France to ban headscarves in state schools.
Thousands of Muslim schoolgirls in France wear headscarves
The Grand Sheikh of the al-Azhar mosque in Egypt, Mohammed Sayed Tantawi, was speaking after talks with French Interior Minister Nicolas Sarkozy.
He said wearing the scarf was a duty for Muslim women - non-Muslim countries could pass any laws they wished.
France says it will ban all conspicuous religious symbols in schools.
President Jacques Chirac says the measure, announced two weeks ago, aims to underline France's secular tradition.
Sheikh Mohammed Sayed Tantawi has to tread a fine line.
He is one of the highest religious authorities in Sunni Islam, but he is also a government employee.
He has to be seen as defending orthodox Islam without upsetting Egypt's relations with a friendly state. Hence the careful choice of words.
Speaking in Cairo in the presence of Mr Sarkozy, Sheikh Tantawi said the veil was the divine obligation of Muslim women.
Some Muslim girls say that they wear the headscarf freely
But he added that that this obligation did not apply if the women lived in a non-Muslim country like France.
He said Muslim women had to obey the rules of the host country in which they live, under what he described as dire necessity.
The choice between evils
This appears to be a reference to a rule in Islamic law which stipulates that when forced to choose between two evils, a Muslim is allowed to choose the lesser one.
In other words, it is less harmful for a Muslim girl in France to refrain from wearing the veil at school than breaking French law.
Sheikh Tantawi's comments will probably go some way towards pleasing the French Government, which apparently wanted to enlist the support of a prestigious institution of Islam in their conflict with French Muslim girls.
But it is difficult to see how these girls will be swayed by the opinion of Sheikh Tantawi.
They do not see France as a host country. They see themselves as French citizens fully entitled to challenge the authority of the state in a modern democracy.