What impelled him to this step we know not, whether it was distaste for the career before him, or purely military enthusiasm. It may well have been the latter, for it was a stirring time; the events, however, which led to the alliance between Spain, Venice, and the Pope, against the common enemy, the Porte, and to the victory of the combined fleets at Lepanto, belong rather to the history of Europe than to the life of Cervantes. He was one of those that sailed from Messina, in September 1571, under the command of Don John of Austria; but on the morning of the 7th of October, when the Turkish fleet was sighted, he was lying below ill with fever. At the news that the enemy was in sight he rose, and, in spite of the remonstrances of his comrades and superiors, insisted on taking his post, saying he preferred death in the service of God and the King to health. His galley, the Marquesa, was in the thick of the fight, and before it was over he had received three gunshot wounds, two in the breast and one in the left hand or arm. On the morning after the battle, according to Navarrete, he had an interview with the commander-in-chief, Don John, who was making a personal inspection of the wounded, one result of which was an addition of three crowns to his pay, and another, apparently, the friendship of his general.
How severely Cervantes was wounded may be inferred from the fact, that with youth, a vigorous frame, and as cheerful and buoyant a temperament as ever invalid had, he was seven months in hospital at Messina before he was discharged. He came out with his left hand permanently disabled; he had lost the use of it, as Mercury told him in the "Viaje del Parnaso" for the greater glory of the right. This, however, did not absolutely unfit him for service, and in April 1572 he joined Manuel Ponce de Leon's company of Lope de Figueroa's regiment, in which, it seems probable, his brother Rodrigo was serving, and shared in the operations of the next three years, including the capture of the Goletta and Tunis. Taking advantage of the lull which followed the recapture of these places by the Turks, he obtained leave to return to Spain, and sailed from Naples in September 1575 on board the Sun galley, in company with his brother Rodrigo, Pedro Carrillo de Quesada, late Governor of the Goletta, and some others, and furnished with letters from Don John of Austria and the Duke of Sesa, the Viceroy of Sicily, recommending him to the King for the command of a company, on account of his services; a dono infelice as events proved. On the 26th they fell in with a squadron of Algerine galleys, and after a stout resistance were overpowered and carried into Algiers.
By means of a ransomed fellow-captive the brothers contrived to inform their family of their condition, and the poor people at Alcala at once strove to raise the ransom money, the father disposing of all he possessed, and the two sisters giving up their marriage portions. But Dali Mami had found on Cervantes the letters addressed to the King by Don John and the Duke of Sesa, and, concluding that his prize must be a person of great consequence, when the money came he refused it scornfully as being altogether insufficient. The owner of Rodrigo, however, was more easily satisfied; ransom was accepted in his case, and it was arranged between the brothers that he should return to Spain and procure a vessel in which he was to come back to Algiers and take off Miguel and as many of their comrades as possible. This was not the first attempt to escape that Cervantes had made. Soon after the commencement of his captivity he induced several of his companions to join him in trying to reach Oran, then a Spanish post, on foot; but after the first day's journey, the Moor who had agreed to act as their guide deserted them, and they had no choice but to return. The second attempt was more disastrous. In a garden outside the city on the sea-shore, he constructed, with the help of the gardener, a Spaniard, a hiding-place, to which he brought, one by one, fourteen of his fellow-captives, keeping them there in secrecy for several months, and supplying them with food through a renegade known as El Dorador, "the Gilder." How he, a captive himself, contrived to do all this, is one of the mysteries of the story. Wild as the project may appear, it was very nearly successful. The vessel procured by Rodrigo made its appearance off the coast, and under cover of night was proceeding to take off the refugees, when the crew were alarmed by a passing fishing boat, and beat a hasty retreat. On renewing the attempt shortly afterwards, they, or a portion of them at least, were taken prisoners, and just as the poor fellows in the garden were exulting in the thought that in a few moments more freedom would be within their grasp, they found themselves surrounded by Turkish troops, horse and foot. The Dorador had revealed the whole scheme to the Dey Hassan.