Did Tolkien use any real cities as basis for his stories? If yes, which cities have counterparts in Middle-Earth?
I think the answer is no, there are no real world counterparts. (Edit: Laketown may be a partial exception, see below.)
The only city described in detail in Tolkien's works is Minas Tirith, and it doesn't bear much resemblance to any historical city. A pre-gunpowder city would typically have a single surrounding wall, and maybe a castle in the centre. Minas Tirith is a "stepped" city with seven levels of concentric fortifications, and a single spiralling main street which tunnels through the big "prow" of rock at the front. Its geography is unique and I'm not aware of anything in our world which even comes close.
The dwarf kingdoms of Moria and the Lonely Mountain might count as cities, but they don't really have counterparts in our world either. Some cities such as Paris and Rome have had inhabited catacombs, but these were cramped tunnels where the some of the poorest members of society lived, not the impressive dwarf halls that Tolkien describes.
As for the other cities in Tolkien's works, the buildings and layout of places like Minas Ithil, Osgiliath, Gondolin, etc. are hardly described at all. As I recall there is a reference in Appendix A of LOTR to a building known as the Dome of Stars in Osgiliath. It says the chief Palantir was cast down into the river when the Dome was destroyed in the fall of the city. This might imply that it was situated on a bridge large enough to support a substantial building; as such it may have been loosely inspired by Tower Bridge in London or the Charles Bridge in Prague. But this is practically the only item of description we have.
The Shire resembles the countryside of southern England very closely indeed, especially Oxfordshire and the Cotswolds, but I wouldn't consider it a city.
Edit: I forgot Laketown, which as a floating city does have some counterparts in our world. See for example: http://weburbanist.com/2012/08/20/water-worlds-15-real-floating-towns-ocean-cities/ Venice and Tenochtitlan (later Mexico City) are similar, although these did start off on naturally ocurring islands.
I don't think Tolkien based Laketown on any specific aquatic city. If anything, he may have been thinking of Venice, which was founded by refugees from the barbarian invasions which destroyed the Roman Empire, in a similar way to the refugees from Smaug's destruction of Dale. And like Venice, Laketown was a substantial trading power. But there are significant differences as well; Venice had access to the open sea, it was much larger and richer than Laketown seems to be, and it is a "southern" Italian city whereas I think Laketown is intended to have a more "northern" English/Germanic feel. In that sense it borrows from trading towns such as Lubeck and other members of the Hanseatic League, and the Russian city-state of Novgorod.
The only city in Lord of the Rings which Tolkien explicitly relates to a real-world city is Minas Tirith, which he relates to Byzantium.
This is done in Letter 131, first of all in the published part (in Letters):
In the south Gondor rises to a peak of power, almost reflecting Númenor, and then fades slowly to decayed Middle Age, a kind of proud, venerable, but increasingly impotent Byzantium.
Then in the part omitted from Letters but subsequently published in Hammond & Scull's Reader's Companion:
Now we come to the half-ruinous Byzantine City of Minas Tirith
("city" is capitalized in the original)
The nature of this relationship is also noted in Hammond & Scull, in the first entry for their commentary on the "Realms in Exile" part of Appendix A:
The division of the Númenórean realms in exile into two kingdoms bears some similarity to the Western and Eastern subdivision of the late Roman Empire. One Empire, Byzantium, long outlasted the other and had periods of great glory, as did Gondor in Middle-earth...
(capitalization/etc as per the original)
In other words, Byzantium is not a direct basis for Minas Tirith, but indirect, in so far as it's a remnant of a much more ancient empire that has otherwise outlived it's heyday and subsequently exists in a kind of faded glory (the difference is, of course, that Gondor is renewed).
A 'hot-off-the-press' answer...
This article in the Guardian refers to recently discovered papers found in a book in an Oxford bookshop:
Hobbiton, he notes, “ is assumed to be approx at latitude of Oxford”
The novelist also uses Belgrade, Cyprus, and Jerusalem as other reference points, and according to Blackwell’s suggests that “the city of Ravenna is the inspiration behind Minas Tirith - a key location in the third book of the Lord of The Rings trilogy”
If you're interested, the map is currently on show/sale in Blackwells, Oxford for a bargain price of £60,000 ($92,029) !
Tolkien had a bunch of versions of his mythology, and one was where England was essentially Tol Eressea, the Elivsh isle far to the West, close to Valinor. The Elves bring Tol Eressea back to Middle Earth for one last great battle, the "Faring Forth", but are fated to lose.
The city of Kortirion on Tol Eressea would then have been renamed Warwick. This is all in the end section of the second Lost Tales Volume. He wrote some poetry about Kortirion, (also found in Lost Tales), but it's barely described any more than that.
The description of Minas Tirith may have been influenced by a number of historical cities.
The round shape could come from the Round City built at Baghdad about 750 AD. This in turn was influenced by the round shapes of a number of Persian cities, allegedly including at least one of the seven cities in the Sassanian complex at Ctesiphon in Iraq, one of the greatest urban complexes in the ancient world.
And one roundish Persian city was Ecbatana, modern Hamadan, where according to Herodotus the first king of the Medes built his place at the top of a hill surrounded by seven concentric walls, though the heights of the successive wall differed by much less than the 100 feet at Minas Tirith.
"The Medes built the city now called Ecbatana, the walls of which are of great size and strength, rising in circles one within the other. The plan of the place is, that each of the walls should out-top the one beyond it by the battlements. The nature of the ground, which is a gentle hill, favors this arrangements in some degree but it is mainly effected by art. The number of the circles is seven, the royal palace and the treasuries standing within the last. The circuit of the outer wall is very nearly the same with that of Athens. On this wall the battlements are white, of the next black, of the third scarlet, of the fourth blue, the fifth orange; all these colors with paint. The last two have their battlements coated respectively with silver and gold. All these fortifications Deioces had caused to be raised for himself and his own palace."
Combining Herodotus's description of Ecbatana with the winding way up Mount St. Michael in France would be the basic idea for the layout of Minas Tirith.
Many other castles, fortresses, and cities have had concentric wall systems. When Tolkien was young, for example, Peking/Beijing still had several concentric rectangular walls. The palace in the Purple Forbidden City had it's walls and was surrounded by the walls of the Imperial City which was surrounded by the walls of the Tartar City where the Manchus Lived. There was also the Chinese city for the subject Chinese, but unfortunately it did not surround the Tartar City but was attached to the south.
And don't forget the Avar Rings of legend. When I first heard of the title Lord of the Rings by J.R.R. Tolkien I thought that it referred to something like the Avar Rings. When the Avars settled in what is now Hungary around 568 they built a supposedly gigantic ring fort.
According to the Life of Charlemagne by the Monk of St. Gall, Book II (which calls the Avars Huns):
"The land of the Huns," he would say, "was surrounded by nine rings."22 I could not think of any rings except our ordinary wicker rings for sheepfolds; and so I asked: "What, in the name of wonder, do you mean, sire?" "Well," he said, "it was fortified by nine hedges." I could not think of any hedges except those that protect our cornfields, so again I asked and he answered: "One ring was as wide, that is, it contained as much within it, as all the country between Tours and Constance. It was fashioned with logs of oak and ash and yew and was twenty feet wide and the same in height. All the space within was filled with hard stones and binding clay; and the surface of these great ramparts was covered with sods and grass. Within the limits of the ring shrubs were planted of such a kind that, when lopped and bent down, they still threw out twigs and leaves. Then between these ramparts hamlets and houses were so arranged that a man's  voice could be made to reach from one to the other. And opposite to the houses, at intervals in those unconquerable walls, were constructed doors of no great size; and through these doors the inhabitants from far and near would pour out on marauding expeditions. The second ring was like the first and was distant twenty Teutonic miles (or forty Italian) from the third ring; and so on to the ninth: though of course the successive rings were each much narrower than the preceding one. But in all the circles the estates and houses were everywhere so arranged that the peal of the trumpet would carry the news of any event from one to the other."
The travel distance from Tours, France to Constance, Germany is 515.7 miles, but probably only about 400 miles or so as the crow flies. If the distance between each ring and the next was always 20 German or 40 Italian miles, the total diameter of the ring system would be about 320 German miles or 640 Italian miles, plus the uncertain diameter of the inner ring.
Growing (or shrinking) cities often built new walls, though the old walls were seldom kept defensible once the new walls were finished.
Rome, for example, had several sets of walls in it's history. The Servian Walls were built in the late Fourth Century BC and were seven miles long. The Servian walls had been disused for a long time when the Aurelian Walls were built in 271 to 275 AD with a length of 12 miles.
In Constantinople, a city which may have been an important inspiration for Minas Tirith, There were many sets of walls, thought not all in use at the same time. The city was on a peninsula between the Golden Horn and the Sea of Mamora.
Emperor Nikephoros II Phocas who ruled from AD 962 to 969 built an innermost wall within the palace grounds, protecting the inner palace around the fabulous Chrysotrichlinos or Golden Hall. The rest of the palace was already protected by walls centuries old, of course.
The wall of the ancient city of Byzantium, built by Septimius Severus (ruled AD 193 to 211) would have been a short distance to the west if it was still maintained. Beyond that there was a long-abandoned fore-wall built before the siege by Constantine in AD 324. To the west of that was the wall wall built by Constantine after he founded Constaninople. And to the west of that were the mighty walls of Theodosius II (ruled AD 408 to 450).
And far beyond the Theodosian Walls were the Long Walls build by Anastasius I (ruled AD 491 to 518).
I suggest that fantasy writers wanting to create a "super Constantinople" as an imperial capital should rotate the map of Constantinople around their equivalent of the Chrysotrichlinos to design a gigantic circular city. Enemy armies trying to get to the emperor would have to fight their way through the equivalents of the Long Walls, the Theodosian Walls, the Constantinian Walls, the fore-wall of Byzantium, the wall of Byzantium, the wall of the palace, and the wall of the inner palace, all kept in repair at the same time in the world of fantasy.
Possibly Tolkien thought of something similar when designing Minas Tirith (though on a much smaller scale).
The fantasy city which most influenced Tolkien's description of Minas Tirith was Plato's description of the capital of Atlantis in Critias. Tolkien might have also read the works of modern theosophists, who sometimes name the capital of of Atlantis as The City of the Golden Gates.
According to Plato's very long description, the citadel with the palaces and temples was on a circular central island with a diameter of five Stadia (about 3,000 feet), surrounded by a ring-shaped canal one stadia (about 600 feet) wide, surrounded by an island two stadia (about 1,200 feet) wide, surrounded by a canal two stadia (about 1,200 feet) wide, surrounded by an island three stadia (about 1,800 feet) wide, surrounded by a canal three stadia (about 1,800 feet)wide.
The concentric islands and canals totaled 27 stadia or about 16,400 feet or 3.10 miles in diameter.
The outer wall of the circular city was fifty stadia (about 30,000 feet) beyond the outermost canal. That makes the radius of the city 63.5 stadia (about 38,500 feet or 7.30 miles) and the diameter 127 Stadia (about 77,000 feet or 14.6 miles).
In short Minas Tirith was mostly based on the description of Ecbatana and on the winding path up to the top of Mount Saint Michael, with other influences from Ctesiphon, Baghdad, Constantinople, Peking/Beijing, The Avar Rings, Atlantis, etc.
The city of Assisi has this huge flat plain in front of it: