Preheat your oven to 180°C (350°F) and lightly grease a medium baking dish with a bit of butter or oil to prevent sticking and make cleanup easier later.
Place a skillet over medium heat and add the butter. Let it melt completely until it starts to gently bubble, but don’t let it brown.
Add the spinach to the skillet and cook, stirring occasionally, until it wilts down completely and reduces in volume. This usually takes a few minutes.
If you’re using frozen spinach, make sure it’s fully thawed beforehand and squeeze out as much water as possible using your hands or a clean kitchen towel. This step is very important to avoid a watery gratin.
Add the minced garlic to the skillet and sauté for about 30–60 seconds, just until it becomes fragrant. Keep stirring and avoid browning the garlic, as it can turn bitter.
Pour in the heavy cream and stir gently to combine with the spinach and garlic. Let it simmer for 2–3 minutes so the cream slightly thickens and develops a richer flavor.
Add the shredded mozzarella and half of the parmesan cheese, stirring continuously until the cheeses melt completely and the mixture becomes smooth, creamy, and well combined.
Season the mixture with salt, black pepper, and a pinch of nutmeg (if using). Stir well so the seasoning is evenly distributed throughout the sauce.
Transfer the creamy spinach mixture into the prepared baking dish and spread it out evenly using a spatula so it cooks uniformly.
Sprinkle the remaining parmesan cheese evenly over the top to create a delicious, golden crust as it bakes.
Place the dish in the preheated oven and bake for 20–25 minutes, or until the top is bubbling and lightly golden brown around the edges.
Remove the dish from the oven and let it rest for about 5 minutes before serving. This helps the sauce set slightly and makes it easier to serve with the perfect creamy texture.