Sclera segmentation is a key component of sclera recognition, which decides the region-of-interest (ROI) for recognition and has a considerable impact on the overall performance. In recent years, a growing interest has been seen in deep learning-based sclera segmentation. Despite their promising segmentation performance for diverse eye images, they are still inherently limited in generalizing to unseen target domains. In this paper, we aim to bridge this gap and learn a generalized sclera segmentation model that can handle new unseen domains well. To this end, we introduce meta-learning in the sclera segmentation problem and propose an effective learning framework, named MetaScleraSeg. Specifically, we first design a meta-sampling strategy to simulate the source/target domain shift in real-world scenarios. Then, a style-invariant UNet 3+ base model is developed for accurate and robust sclera segmentation. To make the base model not only perform well on synthesized source domains but also on synthesized target domains, we employ the bilevel optimization strategy to update the base model, where three useful loss functions are contained. In the experiments, we build a cross-domain sclera segmentation (CDSS) dataset with diverse ethnicity and quality as domain labels to supplement the existing dataset. Besides, three protocols (cross-dataset, cross-ethnicity, and cross-quality) are designed for comprehensively evaluating the generalization of sclera segmentation models. Both quantitative and qualitative experimental results validate the superiority of our method compared to several baselines, which indicates that MetaScleraSeg can learn the transferable knowledge across domains to generalize well on unseen target domains. Models and dataset of this paper are publicly available at https://github.com/lhqqq/MetaScleraSeg. [ABSTRACT FROM AUTHOR]