Qatar and the United Arab Emirates agreed to restore diplomatic relations after a blockade of Qatar by some of its Gulf neighbours was lifted.