In a cast-iron skillet or on a comal set over medium heat, dry-roast the onion and tomatoes until lightly charred, then set aside.
Remove the seeds and stems from the chiles and, using tongs, dry-roast them the same way until fragrant. Place the chiles in a bowl and cover with hot water. Soak for 10 minutes, discard the soaking liquid then transfer to a blender.
Add the onion, tomatoes, garlic, cumin, marjoram, oregano and water to the blender and process to get a smooth mixture.
Strain the mixture through a mesh strainer, if needed. Heat the oil in the skillet and fry the chile mixture for 5 minutes, then add the vinegar, salt and pepper.