In a dramatic end to a tense standoff , Captain Richard Phillips , who commanded the Maersk Alabama cargo ship , was rescued after snipers shot the pirates Sunday evening , after US President Barack Obama approved the use of force to save him , the navy said .