Map from Google - Peru

In Peru, a country located just south of the Equator, there are three climates zones: a desert coastal strip (la Costa), with a mild climate, cloudy and foggy in winter and pleasantly warm in summer; the Andean zone (la Sierra), more or less cold depending on altitude, and finally the large eastern area covered by the Amazonian forest (la Selva), with a hot and humid climate throughout the year.

Peru, climate of the coast
Along the Peruvian coast, the climate is very peculiar. The temperature varies little over the year, and is almost always spring-like, but it almost never rains and therefore the landscape is desert. The reason why along the coast there is a desert, is found in the Humboldt Current, which flows on the ocean and cools the lowest layers of the atmosphere, thereby inhibiting the formation of vertical air currents, which are necessary for the formation of rainclouds. However, this situation in which cold air clings to the soil or the sea surface, leads to the formation of fog and low clouds, which occur often, especially in the cold season, while above 1,650 feet the sunshine prevails, as happens in the Andean locations lying above the foggy layer.
The daily average temperature ranges from 64 °F in the coldest month (August), to 75 °F in the warmest month (February) in the north (see El Alto), from 63 °F to 73 °F in the center (see Lima and Trujillo), and from 59 °F to 72 °F in the south, near the border with Chile (see Ilo).

Fog in Lima

In Lima, the capital, basically it never rains. During winter, from June to September, the sky is almost always cloudy, and there is a mist, the Garúa, which can deposit moisture on the ground; the temperatures are mild, with highs around 64.5 °F, and lows only a few degrees below, but the lack of sunshine and the high humidity make the residents of the capital feel cold, also because they often live in unheated homes. The temperature inversion favors the accumulation of pollutants, despite the proximity of the sea.
During summer, from December to April the sun often shines, at least at noon and in the afternoon, especially in February and March, while in the early hours of the day, fog can still linger on. Even in this season, sometimes low cloud banks can form, albeit more rarely. The temperature is pleasantly warm, with highs around 79 °F from January to March.
Here are the average temperatures of Lima.
Average temperatures - Lima
Min (°F)666666646159595959596164
Max (°F)798179757268666466687275

In Lima, the sea is never very warm, even though it becomes acceptable for swimming from January to March.
Sea temperature - Lima
Sea (°F)727372706666646363636670

In the northern part of the coast, the sea is slightly warmer, and the temperature ranges from 77 °F in February and March, to 70 °F from August to October.
The northern part of the coast (regions of Tumbes and Piura, see Tumbes, Máncora, El Alto, Talara, Paita), may experience a bit of rain from January to May, around 2-4 inches per year. The phenomenon known as El Niño, which is an abnormal warming of ocean waters, can influence this part of the coast (even a little further to the south, up to the region of Lambayeque, see Chiclayo), bringing a warmer weather and unusual rainfall in the years in which it occurs. During the most intense years of El Niño (such as 1983 or 1998), the climate of this area can be transformed, in the first months of the year (from January to May, but sometimes also in the previous December and in June), turning into tropical, hot and humid, with almost monsoonal rains, especially in the northernmost part.
In Lima, usually it does not rain even during these periods, but the torrents that descend from inland can swell, causing floods and landslides. Furthermore, the air temperature can exceed 85 °F in summer, and the sea temperature can exceed 77 °F.

Peru, climate of the Andes
The Andes cross Peru from north to south, sharply separating the coast from the Amazon forest. Here the climate varies with altitude and slope exposure. There are several high peaks, among which Huascaran, with its 22,205 feet high, Yerupajá, 21,710 feet high, and Coropuna, 21,080 feet high. Eternal snows are found at about 16,400 feet.
In the Andean Plateau, home to several modern cities but also the ruins of pre-Columbian civilizations, there is a rainy season from September to May, and a dry season from June to August (but in the far south the rainy season is shorter, so that there is little rain even in September and May). In contrast with the coast, the plateau in the dry season is sunny. The tropical sun rays are very strong, especially at high altitude, hence they raise a lot of the daytime temperature, but at night with clear skies it can get cold, even with possible frosts, especially in the south, which lies farther from the Equator, and thus has a cooler winter.
In the Andean region, rainfall varies depending on slope exposure.
The western side is desert, and here it hardly ever rains: in Arequipa, at 8,200 feet above sea level, less than 4 in of rain fall on average each year. Here is the average precipitation.
Average precipitation - Arequipa
Prec. (in)

The temperature is mild, with cold nights, throughout the year, but especially from May to September.
Average temperatures - Arequipa
Min (°F)484848454343434343454546
Max (°F)727070727270707272737372

The area of Nazca, where the famous and mysterious Nazca Lines are found, is also a desert (called Nazca or Sechura Desert), and is located around 1,640 feet above sea level, so it's not in the Andes, but halfway between the Andes and the coast, where you can find hot temperatures during the day.
The plateau is generally arid, or at most moderately rainy: on average, from 14 to 31.5 inches of rain per year fall; rainfall is a bit more abundant in the north, where the rainy season is longer.
The eastern mountain range, called Cordillera Oriental, is rainier than the western one.
The daytime temperatures in the Andean area do not vary by much during the year, while the nights are colder in the winter months, especially in the south. At night, the temperature can drop below freezing above 10,000 feet, from May to August.

Machu Picchu

In Cusco, the ancient capital of the Inca empire, located at 11,000 feet above sea level, the maximum temperatures vary little throughout the year: from 66 °F from January to July, to 70 °F in October and November (the spring months, which come before the rainy season, are the warmest), while the minimum temperatures fluctuate more: from 45 °F in the period from December to February (which are the summer months) to 34 °F in June and July.
Average temperatures - Cusco
Min (°F)454543413734343641434345
Max (°F)666666666666666868707068

From May to August, it almost never rains, while about 28 inches of rain fall per year, almost all in the period from October to April, and especially from December to March, when rainfall is more frequent and abundant.
Here is the average precipitation.
Average precipitation - Cusco
Prec. (in)

The famous archaeological site of Machu Picchu, located at about 8,200 feet above sea level, is a little milder.
On the shores of Lake Titicaca, divided between Peru and Bolivia, at 12,500 feet above sea level, the climate is colder than in Cuzco, so much so that from May to September there are frequent frosts. In winter, when clear skies prevail, the range between night and day is remarkable, so that during the day the temperature is similar to that of the summer months. Here are the average temperatures of Juliaca.
Average temperatures - Juliaca
Min (°F)373737342721192330323637
Max (°F)636363636361616363646664

In the north, in Cajamarca, at 8,500 feet, the temperature is milder, around 55/59 °F throughout the year, but with a high diurnal range: lows are a few degrees above freezing in winter, and below 50 °F in summer, while highs are just above 68 °F all year round.
Average temperatures - Cajamarca
Min (°F)454545434137373941434343
Max (°F)727070707270707272727272

The rainiest period runs from October to April. Here is the average precipitation.
Average precipitation - Cajamarca
Prec. (in)

Peru, climate of the Amazon rainforest
In the vast area of plains and hills of eastern Peru, belonging to the Amazon Basin, there is a impenetrable rainforest, almost completely uninhabited. The northern region has an equatorial climate, hot and humid all year round, with frequent rainfall, while in the south the climate becomes tropical, with a relatively dry season in winter.
In Iquitos, in the north, almost 120 inches of rain per year fall; the only months when the rainfall decreases a bit are July and August, with around 6 inches of rain per month. The tropical rains usually occur in the afternoon and in the form of downpour or thunderstorm. Here is the average precipitation.
Average precipitation - Iquitos
Prec. (in)1010.813.81210.

The temperatures in this northern part of the Amazon are steadily high all year round.
Average temperatures - Iquitos
Min (°F)727272727272707070727272
Max (°F)889088888686868890909088

Moving south, the relatively dry season in the Southern Hemisphere winter becomes more evident: in Pucallpa, in the central area, just 2/2.4 inches of rain per month fall in the period from June to August, while in the southern part, in Puerto Maldonado, the least rainy season extends from May to September. Here during winter there is also a decrease in temperature, so that the minimum goes down to about 59 °F on average.
The highest rainfall amount is recorded in the eastern slope of the Andes, where the mountains descend to the Amazon rainforest. Quince Mil, at 2,130 feet above sea level, on the north side of the Cordillera Oriental, receives 255 inches of rain per year! Here the "best" period is from May to September, when "only" 12 to 14 inches of rain fall per month.

When to go

It's not possible to find a single period in which the whole Peru offers its best weather, because the best time in the Andean areas and in the Amazon is the Southern Hemisphere winter (June to August), while along the coast during this period the weather is cool, cloudy and foggy. To find a warm and sunny weather, along the coast and in Lima, the best time is from December to April, and for swimming in particular the best period is from January to March.

What to pack

In winter (June to August): for Lima and the coast, clothes for spring and autumn, a sweatshirt or sweater and a jacket. For the Amazon, loose fitting, light clothing, possibly with long sleeves for mosquitoes; a sweatshirt for the evening; a sweater and a jacket for the evening in the southern part (see Puerto Maldonado), and also for the hilly part of the Amazon. For the Andes, in towns at around 8,00/13,000 feet, like Cuzco, Arequipa and Lake Titicaca, clothes for spring and autumn for the day, as well as a sweater, warm jacket and hat for the evening; sun hat, sunscreen, hiking shoes. For the highest peaks, down jacket, scarf, gloves, warm boots.

In summer (December to February): for Lima and the coast, light clothing, a sweatshirt for the evening, umbrella or light raincoat north of Lima for the years of El Niño, a light jacket for the southern part of the coast. For the Amazon, tropics-friendly, loose fitting clothing, of natural fibers (cotton, linen) or synthetics that breathe, maybe with long sleeves for mosquitoes; sweatshirt or light jacket for the evening in the hilly part of the Amazon. For the Andes, in towns at around 8,00/13,000 feet, like Cuzco, Arequipa and Lake Titicaca, clothes for spring and autumn, light for the day, as well as sweater, jacket and hat for the evening; sun hat, sunscreen, umbrella or raincoat, hiking shoes. For the highest peaks, down jacket, scarf, gloves, warm boots.