The deal that enraged Qatar's neighbours Doha paid up to $1bn to an al-Qaeda affiliate and Iran to release members of the Gulf state's royal family who were kidnapped in Iraq while on a hunting trip, according to people involved.