Don Ruy Gonzáles de Clavijo, a Castilian ambassador, was probably the first European to visit Tehran, stopping in July 1404, while on a journey to Samarkand (now in Uzbekistan) and the Mongol capital at the time. At this time, the city of Tehran was unwalled. Tehran became a residence of the Safavid rulers in the 17th century. Tahmasp I built a bazaar and a wall around the city, but it somewhat fell out of favour after Abbas I turned sick when he was passing the city to go to a war with the Uzbeks. In the early 18th century, Karim Khan Zand ordered a palace, a harem, and a government office to be built in Tehran, possibly to declare the city his capital, but later moved his government to Shiraz.