Put the tomatoes, onion and garlic on a baking sheet lined with foil. Place under the broiler for about 10 minutes until charred, mushy, and soft, flipping once halfway through. Remove from the oven and once cool enough to handle, peel the garlic cloves. (Alternatively, you can char and toast on a preheated comal or skillet set over medium-low heat.)
Place tomatoes, peeled garlic and onion in the jar of a blender.
Toast the guajillo and ancho chiles on a heated comal or skillet for about a minute, flipping a few times, until lightly browned and fragrant. Place the chiles in a medium saucepan, cover with water, and simmer about 10 minutes until soft and rehydrated.
Transfer the rehydrated chiles, along with 1 cup of their cooking liquid, to the blender with the other ingredients. Add in the orange juice, vinegar, piloncillo, marjoram, thyme, oregano, salt, and pepper and puree until completely smooth. Let cool.