Slice onion into ¼” semi-circles or quarter circles. Slice garlic as thinly as possible.
Heat butter in a large, heavy pan over medium heat.
When hot, add onion and stir frequently. Cook until almost translucent and starting to caramelize- about 5 minutes.
Add garlic, salt, and pepper. Continue cooking, stirring frequently, until onion is translucent and the liquid from the onion is milky - another 3-4 minutes.
Add sugar and stir to coat all the onions. Add wine. Stir to combine everything then reduce heat to low. Simmer, stirring occasionally, until wine is mostly reduced to a thick syrup - about 40 minutes.
Add lemon juice and stir vigorously. Continue to simmer until all liquid is reduced and onion mixture falls in coated clumps from the spoon. Remove from heat.
Add further salt and pepper to taste. Immediately dispense into jars and tighten the lids. Store in the fridge.