Heat oil in a medium saucepan over medium-high heat. Cook onion, garlic, salt, and pepper until onion is translucent, about 5 minutes. Stir in chili powder, and cook until fragrant, about 1 minute.
Add tomatoes, 3/4 cup water, the sugar, and ketchup. Bring to a boil. Reduce heat, and simmer, partially covered and stirring occasionally, for 1 1/2 hours. Add more water as needed to avoid scorching. Let cool slightly.
Working in batches, puree sauce in a blender. Stir in vinegar; season with salt and pepper. Let cool.