In September 1796, Spain's entry into the war as an ally of France prompted the British fleet to abandon the Mediterranean, where it was in danger of becoming seriously outnumbered, and retreat to Gibraltar. While at anchor off Rosia Bay on 10 December, "Gibraltar" was caught in a storm that drove her on to rocks on the western shore of the Bay of Gibraltar before she was blown across to safety in the Strait of Gibraltar. The ship was sent back to England for extensive repairs to her hull and Jervis gave Brenton a temporary position in Vice Admiral William Waldegrave's flagship HMS "Barfleur".