They had to obtain special documents, which they were told could take up to three weeks. They were fretting as they cannot afford to stay in China and wanted to bring Lily home for medical care.
But yesterday morning the ministry issued the documents, meaning Lily can come home as soon as she has been cleared by her doctors to fly and a medical evacuation flight can be organised.
The ministry said it had also provided the couple with an interpreter, facilitated the extension of their own visas so there was no risk of their being removed from China without Lily and was assisting them in finding the maternity equipment they needed and accommodation near the Shanghai Children's Medical Centre.
A spokeswoman said the ministry could provide advice on paying Lily's hospital expenses, but could not fund medical repatriation to New Zealand.
"New Zealanders travelling or living overseas should have comprehensive travel insurance policies in place that include provision for medical evacuation by air. The ministry advises that insurance covers personal circumstances, both for pre-existing conditions and the activities New Zealanders plan to undertake."
The Hewgills had travel insurance and said it was helping them, but it did not extend to covering Lily's expenses.
Mrs Hewgill's mother, Eileen Ryan, was relieved to hear "things are beginning to move in a good direction". She said the past few days had been "torture".
Mr Hewgill said: "Once in New Zealand, Lily will be fully covered by the public health system and we can see her and help her develop into a healthy child."
A fundraising page set up to help with Lily's hospital care had raised more than $9200 by 4pm yesterday.
If you want to help the Hewgill family visit:
givealittle.co.nz/cause/GetLilyHome