What is the function of the ovary in a flower?

The ovary contains ovules, which develop into seeds after fertilization. The ovary itself matures into fruit, protecting and dispersing the seeds.