Brazil has pulled out of a United Nations pact on dealing with rising migration, joining the United States and a growing number of countries in rejecting the agreement, a Brazilian diplomat with direct knowledge of the matter said on Tuesday.