China borders a number of volatile states , including Pakistan and North Korea , and the country 's leaders have struggled to maintain order within the country , particularly in Tibet and Xinjiang , where ethnic minorities have chafed against rule from Beijing .