There follows a series of adventures, in the course of which Hornblower is learning his trade and also discovering things about himself. He does well and is due to be examined for promotion to lieutenant at Gibraltar. He is asked a question he cannot answer and is about to fail when the examination is halted by an attack by fireships. Hornblower takes part in the saving of the fleet.
In the final chapter he is taking a prize back to England as Acting-Lieutenant, accompanied by a supposed duchess who is really an actress. In a dense fog at night he sails into the middle of a Spanish fleet, and when the fog lifts he is captured. But he gives the secret dispatches he is charged with to the pseudo-duchess, who conceals them under he clothes and eventually takes them to London.
Meanwhile Hornblower is now a prisoner on the Spanish coast. News comes of his promotion to full Lieutenant. He is frustrated by the inactivity but takes the opportunity to learn Spanish, which will turn out to be useful in his later career. When a Spanish ship is wrecked on a reef he organises a daring rescue of the survivors. In the process he is offered the chance to break his parole and escape in a British ship, but after a brief internal struggle he returns to captivity. But a few months later he is set free by order of the First Minister in recognition of his courage and self-sacrifice in saving life.