A Pakistani court has sentenced Imran Khan to 14 years in prison, setting up a clash with senior figures in the Trump administration who have been campaigning for his release.