Preheat the oven to 375°F (190°C).
Grease a 9x13-inch baking dish with butter or non-stick spray.
In a saucepan, melt the butter over medium heat. Stir in the garlic and cook for 1 minute.
Add the flour and whisk continuously for 2 minutes to create a roux.
Slowly pour in the milk, whisking to prevent lumps. Bring to a gentle simmer and let it thicken.
Stir in 1 1/2 cups of cheese until melted and smooth. Season with salt and pepper.
Layer half the potatoes in the prepared baking dish. Pour half the cheese sauce over the potatoes.
Repeat with the remaining potatoes and cheese sauce.
Sprinkle the remaining 1/2 cup of cheese over the top.
Cover with foil and bake for 40 minutes. Remove the foil and bake for an additional 20 minutes, or until the top is golden and bubbly.
Let cool for 10 minutes before serving.