Go to Lilycove, then travel toward Slateport City. Before Cycling Road, talk to Captain Stern while he is being interviewed. After Team Aqua steals the submarine, return to Lilycove and enter the hideout. Also grab the Master Ball inside, because it will disappear later.