The OED's first quotation is 1822 but I found an antedating almost a century earlier. It appears in A new account of the East Indies: being the observations and Remarks of Capt. Alexander Hamilton (1727, Volume 1, page 254):
And the Virgin Mary, to shew her Kindness, and Skill in Navigation, stood a whole Night on the Forecastle, directing the Devil how he mould steer, and behold, to the great Admiration of all concerned, the Ship was high and dry in the Morning, in a Valley on the South Side of the River of Goa, about half a Mile within the land.
I'll include the full section as it's quite a tale.
The church is A Igreja de Nossa Senhora da Ajuda (or The Church of Our Lady of Help) in Ribandar, on the banks of the Goa river.
The Ribandar website tells the same tale:
The Church of Nossa Senhora da Ajuda (Our Lady of Help), which is situated at a little distance from the hospital, makes up Ribandar's important landmark of all. A legend claims that the church owes its construction to the miraculous appearance of the Virgin Mary, to save a Portuguese ship which was caught in the eye of a terrible storm at the Arabian Sea. The Virgin Mary herself is said to have stood on the forecastle throughout that fateful night, directing the devil (!) himself to steer the ship to safety. To commemorate the miracle the beautiful church stands where that ship had found a safe mooring, the edifice being just the length, breadth and height of the legendary ship.
Finally, here's a photo of the church's ship on wheels.