The Supreme Court has ruled against the UK government by a vote of 8 to 3, necessitating a vote by Parliament.