A navy officer put in charge of Mexico’s second-largest port in an effort to wrest control of it from a drug gang was shot and killed in what the authorities said Thursday was a robbery attempt. The officer, Rear Adm. José Luis Corro Chávez, was shot Wednesday after he refused to leave his vehicle when gunmen demanded it outside his house in the port city of Lázaro Cárdenas, in Michoacán State. Two suspects have been arrested. Admiral Corro had served at the port since November 2013, when the navy began trying to root out the Knights Templar gang, which had been smuggling iron ore to China and extorting mining interests in the area. The authorities said the shooting was not related to organized crime, but it came nearly a week after the arrest of the former top leader of the Knights Templar, Servando Gómez.