Porto's Atlantic climate means mild temperatures year-round but a significant amount of rain, especially from October through February. The city's nickname — a cidade da chuva (the city of rain) — is earned, and the north Portuguese coast gets more precipitation than most of continental Europe at the same latitude.
The best time to visit is May and June, when the weather is reliably warm and dry, the city is busy but not overwhelmed, and the evening light lasts well past 9pm. September is similarly good — summer's heat has passed, the crowds thin, and the Douro wine harvest season begins upriver. July and August bring reliable sun and heat but also the largest tourist numbers; accommodation prices are at their highest and the Ribeira's restaurants have their longest queues.
Winter has its partisans: Porto in January is uncrowded, the light on grey days falls beautifully on the granite and tiles, and the city's indoor life — the cafés, the fado houses, the bars — is at its most authentic. Rainfall is the main hazard; a good waterproof and the knowledge that bad weather typically alternates with clear cold days makes winter very manageable. The Festa de São João on June 23rd is Porto's great civic celebration — the streets of the historic centre fill with people hitting each other with plastic hammers and setting off fireworks. If you are there, don't miss it.