The prisoner exchange was brokered with the help of the United Arab Emirates, officials said.