The United States, Denmark and Greenland signed a security agreement on Tuesday aimed at ending months of tension over the Danish self-governing territory after US President Donald Trump's repeated threats to take control of the vast Arctic island.