Courts have ordered royalist government to free 17 political detainees, including senior opposition leaders, officials said.