In 1676, he fought the French in the Battle of Palermo, where his brother and father were killed. He then became a company commander in the Caribbean, guarding Spanish ships and colonies from foreign attackers and pirates. He earned a reputation for outstanding bravery and efficiency, being wounded five times.