They were supposed to trade one island paradise for another: a monthlong sailing trip in spring, from Honolulu to Tahiti.

But on Wednesday morning, they were discovered in the wrong hemisphere, 5,000 miles off course and nearly six months into a dream that had curdled into a nightmare.

Jennifer Appel and Tasha Fuiaba were rescued by the Navy vessel the Ashland 900 miles south of Japan, according to a statement released by the Navy on Thursday. After setting out in early May, a storm claimed their 50-foot boat’s engine on May 30. They spent the next five months adrift at sea and unable to make contact with others.

The two friends survived on a water purifier and a store of oatmeal, pasta and rice, with two pet dogs, Zeus and Valentine, to keep them company.