Entering the navy in 1837, at the age of 12, he took part in the Battle of Socabaya (1838), during the War of the Confederation that led to the fall of Marshal Andrés de Santa Cruz. Next, he sought a wider field, and saw active service in the First Opium War on board the British frigate HMS "Calliope" and the third rate ship of the line HMS "Blenheim". He was mentioned in despatches for bravery, and received the grade of midshipman in the Royal Navy.