MPs have defeated the Government on an amendment which could thwart efforts by the next prime minister to force through a no-deal Brexit.