A deal has been agreed between the UK and the European Union, allowing Brexit negotiations to move on to the next stage, pending a vote in the European Parliament.