Nowadays, the smart city trend has attracted an important number of municipalities, enabling to control and manage smartly the city environment and provide the citizens with value‐added urban services. In this regard, Internet of Things and fog computing play a key role in providing smart city services, simplifying the decision making for city authorities and improving the quality of experience (QoE) for citizens. In this article, we address the problem of selecting appropriate urban service providers and their sequencing given the citizen request for a set of urban services (eg, banks, laundries, carwashes, gas stations, bakeries) considering a number of quality metrics. This latter can be translated into a service composition problem with the aim of optimizing the QoE of citizens, the load of service providers and the roads traffic. In such a context, the first contribution of this article consists of proposing a fog‐based fault‐tolerant architecture capable to address the scalability and reliability issues of smart cities, while processing efficiently and reactively the service composition requests of citizens. In addition, we map the QoE‐aware service composition problem in smart cities to a generalized traveling salesman problem and propose three metaheuristics based on genetic algorithms, particle swarm optimization, and artificial bee colony to solve this problem in a timely manner. The results obtained based on the developed prototype of our proposal demonstrate the superiority of our proposed approach compared with other existing service composition alternatives.