Place the dry beans in a large pot and cover with cool water, filling the bowl about 2 inches above the beans. Let soak for 8 hours or overnight.
Drain the beans, discarding the soaking water, and rinse.
Place the beans back in the pot, cover them with water by a couple of inches, and bring the water to a boil.
Lower the heat and let simmer for about an hour until tender. Drain and set aside.
Meanwhile, cut the dried ancho chiles in half and remove the stems and seeds. (Keep the seeds if you want the baked beans to be even spicier.)
Rehydrate the chiles by placing them in a bowl, covering them with hot water, and letting them sit for 30 minutes.
Drain the chiles, reserving a few tablespoons of the water.
Puree the chiles in a food processor, adding some of the reserved water if needed. Set aside.
Preheat the oven to 325 F.
Heat the oil in a Dutch oven on medium.
Add the onion and saute for 5-6 minutes until softened.
Add the garlic and saute for 1-2 more minutes.
Transfer the drained beans, ancho chile puree, and all the remaining ingredients to the pot and stir well. Let the mixture come to a simmer and let simmer for 2 minutes before removing from the heat.
Put the lid on the pot and transfer it to the oven. Bake for about 1 ½ hours until thickened. Stir it once halfway, and if there seems to be too much liquid, uncover the pot for the second half of baking.