A man who married a 12-year-old girl in an Islamic ceremony in New South Wales has been jailed for at least seven and a half years.

The 27-year-old man pleaded guilty to the charge of the persistent sexual abuse of a child after he told police he married the girl in the Hunter Valley in 2014.

After he was charged an examination at Westmead Children's Hospital confirmed the girl had an ectopic pregnancy and miscarried.

She was examined after she complained of stomach pain.

Court papers showed the man started texting the girl after he became aware of her at a mosque in late 2013.

The girl, who is now 13, is in the care of authorities

In the NSW District Court Judge Deborah Sweeney gave the man, who cannot be named, a maximum sentence of 10 years with a non-parole period of seven and a half years.

He will be eligible for parole in August 2021.

He faced a possible 25-year sentence for the offence.