The court heard the teenagers, who cannot be named for legal reasons, approached Osmani, from Northampton, after being turned away by another mosque.

He agreed to carry out the non-legally binding Islamic nikah ceremony and charged £50 for a certificate.

After the ceremony, the court heard, the couple celebrated with friends.

Defence barrister James Gray said Osmani had made one mistake in 20 years of conducting nikah ceremonies.

Gray told the hearing Osmani had asked for passports to check dates of birth, completed an application form and filled in the mosque register correctly.

“All of those things combine to make it quite clear that he was labouring under a mistake as to the change in the law.

“Had he known of the change in the law he wouldn’t have done it,” Gray said.

Addressing Osmani, the judge told him: “Your approach can only be described as negligent. You ought to have known the law had changed.”

Osmani left the court without comment, and covered his face with his hands and a scarf.