Jack Aubrey and Stephen Maturin, a medical man of science, are close, particular friends of long acquaintance, having sailed together on previous occasions. They again join together on a prolonged voyage of the H.M.S. Surprise, a Royal Navy frigate. Captain Aubrey is entrusted with the task of transporting a political delegation to Kampong, many thousands of miles distant. On the way Aubrey and Maturin worry about Sophie Williams and Diana Villiers—their respective love interests. Unfortunately, the ambassador dies of ill health when the journey is nearly complete and Aubrey turns the ship around. He falls in with an English fleet under attack from a French naval squadron and leads a spectacular and successful defense before landing at Calcutta for repairs. In Calcutta, Maturin engages Diana's lover in a pistol duel and kills his opponent while receiving a dreadful wound to the chest. Maturin subsequently extracts the ball by himself and the two men return home, the remainder of their voyage being relatively uneventful.

The novel is the third in a series of twenty dealing with the experiences and adventures of Captain Jack Aubrey, Royal Navy, and Stephen Maturin, man of science and medicine. As such, the novel presupposes the reader has a certain familiarity with the principle characters including Aubrey, Maturin, Sophie Williams, and Diana Villiers. Although the various relationships and current situations of the four characters are glossed over, the sparse detail given would seem to indicate their relationships are not of paramount importance to the plot, which is in fact not the case.

The novel opens with an exciting rescue sequence; an over-confident Maturin accepts a poorly-considered mission of secret intelligence which results in his capture, imprisonment, and torture. Aubrey, in temporary command of a frigate returning to England, learns of Maturin's plight and executes a daring rescue. The two men then return home where Aubrey, supremely skilled on the water but nearly incompetent ashore, surrenders command of the frigate to the normal captain and is then arrested and imprisoned for debt due to a series of ill-considered fiduciary transactions conducted in a previous novel. Meanwhile Maturin gradually recovers his health and regains the use of his shattered body.

Maturin's friends in the intelligence service desire to rehabilitate his reputation as a man of learning and medicine, and therefore contrive to send him on a prolonged errand through scientifically largely unexplored areas; he will thus be enabled to publish monographs and regain his scientific reputation. Maturin's particular friend Aubrey is selected to captain the ship which will perform the errand of delivering a political ambassador to a distant kingdom. The two men are thus assigned to H.M.S. Surprise and quickly board and leave England. The remainder of the novel treats their experiences sailing to and from India.

On the trip, the ambassador dies and Aubrey turns the ship around, commenting on the frustration of having run a fool's errand. The ship then falls in with a returning fleet of Indiamen plying the far-East trade. The fleet is harried by a French squadron. Aubrey organizes an unlikely but spirited defense; although his ship suffers severe damage, his plan thwarts the French attack and Aubrey is once again regaled as a masterful captain and leader of men. The ship then stops at Calcutta for repairs. While there, Maturin meets his love interest, Diana Villiers, living in a scandalous affair with one Mr. Canning. The inflammatory Canning strikes Maturin on one occasion, and Maturin takes the opportunity to demand satisfaction of honor. A pistol duel ensues and Maturin kills Canning but receives in return a dreadful shot to the chest. In a memorable but unlikely surgical scene, Maturin uses a large mirror to extract the ball from his own chest. Upon his urging, Diana returns to England aboard a non-military vessel; she leads the wounded and sick Maturin to believe they have become engaged and will be wed in England.

The main action of the novel concluded, Maturin and Aubrey return home via a long voyage which proves mostly uneventful. They reach home to discover that the honorable Sophie eagerly awaits Aubrey's return in anticipation of marriage; the beautiful but faithless Diana, however, has met yet another rich young man and absconded with him to America, leaving Maturin depressed and alone.