Late spring (April–early June) and early autumn (September–October) are best. The light is good for the brick architecture and the hills are green; daytime temperatures are 18–25°C. July and August can be hot (30°C+) and the university is closed, leaving the city quieter than usual.
The big local event is the Festa del Duca in late August, when the town puts on three days of medieval pageantry — costumed processions, flag-throwing, archery contests, a Renaissance-themed banquet — commemorating Federico da Montefeltro's golden age. Worth timing a visit for.
White truffle season runs October through December and the surrounding hills (Acqualagna in particular) host truffle fairs throughout this period. The roads up to Urbino can be foggy and icy in winter, but the city under snow is beautiful.