What's more important: service & ambience or food?

While I was sitting in a lovely restaurant in Spain I was thinking about the most important thing that makes eating in a restaurant a great experience. Is it really the food? I ate in a restaurant last Monday that hadn’t served great food. But I felt so welcomed: The prices were moderate, the waiter was just phenomenal and the dining room was nicely decorated. In contrast, I’ve dined in so many restaurants that served great food but they were either overprized or the service was just horrible (sometimes even both applied). If I have to decide between a great ambience and great food… well I would most of the time go for the ambience.