From the UNHCR: "The 1951 Convention relating to the Status of Refugees is the key legal document in defining who is a refugee, their rights and the legal obligations of states." The 1951 Convention and its 1967 Protocol are legally binding international treaties, from which the global definition of a refugee is derived, as any person who:
“owing to well-founded fear of being persecuted for reasons of race, religion, nationality, membership of a particular social group or political opinion, is out-side the country of his nationality and is unable or, owing to such fear, is unwilling to avail himself of the protection of that country; or who, not having a nationality and being outside the country of his former habitual residence as a result of such events, is unable or, owing to such fear, is unwilling to return to it.”
The 1967 Protocol lifted the temporal and geographic restrictions of the 1951 Convention, which was focused on post-World War II Europe, making the refugee law global and enduring.
At a regional level there is also the Cartagena Declaration, adopted by ten Latin American countries, primarily in Central America. Although it is not binding like the 1951 Refugee Convention or 1967 Protocol, the Cartagena Declaration is notable for expanding the definition of a refugee in a Central American context.
From the UNHCR: "Internally displaced persons, or IDPs, are among the world's most vulnerable people. Unlike refugees, IDPs have not crossed an international border to find sanctuary but have remained inside their home countries. Even if they have fled for similar reasons as refugees (armed conflict, generalized violence, human rights violations), IDPs legally remain under the protection of their own government - even though that government might be the cause of their flight. As citizens, they retain all of their rights and protection under both human rights and international humanitarian law."
Unlike with refugees, there is no universal, legally-binding, international treaty specifically regarding the treatment of IDPs. However, there are guiding principles, which serve as an important normative framework at the global level:
At a regional level, there are legally binding agreements regarding IDPs, applicable in areas of Africa:
From the UNHCR: "Nationality is a legal bond between a state and an individual, and statelessness refers to the condition of an individual who is not considered as a national by any state."
The U.N. High Commissioner for Refugees is mandated to lead and coordinate international action to protect refugees and resolve refugee problems worldwide. Its primary purpose is to safeguard the rights and well-being of refugees. However, UNHCR’s formal mandate was expanded in 1995 to also “identify stateless people, prevent and reduce statelessness around the world, as well as to protect the rights of stateless people.” (Source: http://www.unhcr.org/en-us/how-unhcr-helps-stateless-people.html)