"Caught between the devil and the deep blue sea", meaning you had two outcomes and neither of them was going to be good.
The "devil" was the area of the hull of a sailing ship where it curved toward the keel. The devil collected barnacles, which had to be removed occasionally.
At sea, the way to do that was to heel over the ship as far as possible and lower a sailor on a rope to scrape as fast as he could until the ship had to come to again.
If he wasn't raised fast enough, the wave (deep blue sea) would smack him against the barnacle-encrusted "devil" and he'd lose some skin or perhaps his life.
Thus, you never wanted to be caught between the two.