Map from Google - Brazil

Brazil is a huge country and has different climates, although it can be divided into three main climatic regions: equatorial with year-round rains (the Amazon Basin plus a small coastal area), almost Mediterranean with temperate winters and hot summers (the extreme south), and finally tropical with a dry season (the vast central area, plus a small northern portion). Northern Brazil is crossed by the Equator, so that south of the Equator, that is in the majority of the country, the seasons are reversed compared with Europe or North America. In the tropical zone, the rainy season is almost always the austral summer.

Areas having an equatorial climate
In a large area of northern Brazil, covered by the Amazon rainforest, the climate is equatorial, hot and humid with year-round rains. The rains come in the form of heavy showers and thunderstorms in the afternoon or evening. The total annual rainfall is considerable, from 80 to 120 inches. The rains are more abundant from December to May, when they easily exceed 8 inches per month, but often even 12 inches. Within the forest, the temperature remains below 85 °F even during the day, but moisture is consistently close to 100%. The cities built in the area, after removing a part of the forest, are a bit warmer, because of course the sun rays are able to reach the ground.
For example, in Manaus, in the middle of the forest, the maximum daytime temperature is around 86/90 °F all year round, but it can reach 95/100 °F in the hottest days; the air is almost always moist. Rainfall amounts to 90 inches per year, of which more than 8 inches per month from December to May, while there's a drier period, with less than 4 inches per month from July to September.
Here is the average precipitation in Manaus.
Average precipitation - Manaus
Prec. (in)10.211.412.411.8104.

Even in Belém it's hot and humid all year round, but at least the city is located near the coast, so it receives a bit of a breeze from the sea.
Here are the average temperatures of Belém.
Average temperatures - Belém
Min (°F)727272727372727272727272
Max (°F)888886888890909090909090

Here the rains are more abundant than in Manaus, and the trend is similar, although the relatively less rainy period is moved forward, reaching a low in October and November. Here is the average precipitation in Belém.
Average precipitation - Belém
Prec. (in)13.415.917.113.611.

The least rainy period runs from August to November in the northern part of the Amazon, and from June to September in the south-central part, but as mentioned there's not a really dry season, because heavy rains are always possible in the afternoon, they are just rarer in the less rainy season. As a result, in this season the hours of sunshine increase a bit, even though their percentage is never too high, because some cloudiness frequently develops.
A climate of this kind, hot and humid with year-round rains, is also found in a relatively small area along the eastern coast (see the small circle in the map), in the area of Salvador de Bahia, which receives 75 inches of rain per year. Here the rains are frequent and abundant especially from April to early August.
Here is the average precipitation.
Average precipitation - Salvador
Prec. (in)34.56.51111.

The temperatures drop slightly during the winter months, from June to August, when highs are around 79/81 °F. The reason why in this stretch of coast it rains throughout the year, is to be found in the trade winds that pick up moisture over the sea, however, downpour and thunderstorm don't last long, so that the sunshine amount remains high, especially from October to March, when there are about 8 hours of sunshine per day on average. In addition, along the coast the sea breeze tempers the heat even in the warmest months. Therefore, the climate of Salvador de Bahia is better than that of the Amazon forest. To explore this fascinating city and hang out at the beaches, you may prefer the period from October to January.
Average temperatures - Salvador
Min (°F)757575737372707072737373
Max (°F)868686848281797981828484

In Salvador, the sea is warm all year round, as you can see in the following table.
Sea temperature - Salvador
Sea (°F)828282828281797979798181

Areas having a tropical climate
In this vast area including most of the central and southern Brazil, the climate is tropical, with a dry season (usually from May to August) and a rainy season (typically from October to March, with the peak in mid-summer, between December and February). In the areas where the dry season is shortest, the forest can grow as happens in the equatorial zone, otherwise the vegetation is less dense and savanna-type, with characteristics of more or less pronounced aridity (presence of shrubs, cacti, etc..). For example, in inland areas of the states of Bahia and Pernambuco, precipitation decreases to 15.5/20 inches per year, and there are many days with intense heat, especially between August and November. However, the rainfall in inland areas of the Nordeste are very irregular, so even though the average is not very high, in the period from November to March, in some years there may be even torrential rains.
Anyway, in many places, the altitude, between 1,650 and 3,300 feet in many eastern areas, tempers the heat a little.

In the far north of Brazil, where the Massif of Guyana is located (see the circled area in the top of the map), we find another area covered by savannah, north of the vast Amazon rainforest. Here we are, albeit slightly, north of the Equator, so the driest period, which is usually the Northern Hemisphere winter, is reversed. In the nort of the state of Roraima, on the border with Venezuela and Guyana, the least rainy period goes from October to March.
Here is the average precipitation in Boa Vista, capital of the state of Roraima.
Average precipitation - Boa Vista
Boa VistaJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (in)0.80.825.110.614.2138.

In Boa Vista, the heat is felt throughout the year; in the dry season the temperatures are higher, but the relative humidity is lower.
Here are the average temperatures.
Average temperatures - Boa Vista
Boa VistaJanFebMarAprMayJunJulAugSepOctNovDec
Min (°F)737375757372727373757573
Max (°F)919193918886869091939191

Further east, in the northern part of the state of Amapá, the least rainy period is shorter and runs from September to November.

Moving down to the greater tropical area, we will follow the rainfall pattern along the coast, which compared with the inland areas is more variable, and determines the best time to visit the different areas.
In the Northeast, east of Belém (which is still part of the equatorial zone), we find cities like Sao Luis, where the dry season runs from August to November, but all in all in December it doesn't exceed 3.5 in, and Fortaleza where it goes from August to December, while in both cases from February to April the rainfall exceeds 8 inches per month. In Fortaleza, in the state of Ceará, the year is curiously divided into two, with the first part dry and the second rainy.
Here is the average precipitation in Fortaleza.
Average precipitation - Fortaleza
Prec. (in)

The temperature in Fortaleza is high throughout the year, but the heat is tempered by breezes. The humidity is higher in the rainy period. Here are the average temperatures.
Average temperatures - Fortaleza
Min (°F)777375737372727373777577
Max (°F)888686868486868484888888

Even in Fortaleza the sea is warm all year round.
Sea temperature - Fortaleza
Sea (°F)828282828282818181818181

Further to the south-east, in Natal, the dry season goes from October to December, but also in September and January the amount of rainfall is usually acceptable. On the contrary, from February to July, more than 12 inches of rain per month fall. Similar trend is found in Recife: here the least rainy period runs from October to January, while in Maceió and Aracaju, it goes from October to February. Further south, the coast of the state of Bahia, where Salvador and Ilheus are found, should be excluded because it's part of the equatorial climate zone, of which we have already spoken.
Further south, we find the area of Rio de Janeiro, where the dry season runs from June to August, that is in winter, as happens in many inland areas of this tropical climate area.
Here is the average precipitation.
Average precipitation - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (in)

Here, however, we are quite in the south, that is, away enough from the equator, to experience a drop in the winter temperature: in Rio the maxima from May to October go down to around 77/80 °F. This can be considered as the best time to visit the city of Rio, because it's warm but not hot, the amount of sunshine is good, and the rains quite rare, even though they are still possible. However, the sea at this time is a bit cool (see below), so for swimming it's better the summer, from January to March, when the heat is intense, with possible heat waves (the temperatures can touch 99/100 °F), heavy rains in the afternoon can occur, but the amount of sunshine is still fairly good and the sea is warm. Not by chance, during this period the Rio Carnival takes place, reflecting the fact that the climate is not so bad even in this period, in fact the heat enhances the vitality of the Brazilian people.
Average temperatures - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDec
Min (°F)737573726866646666687072
Max (°F)848684827977777977798184

In Rio de Janeiro you can swim all year round, even though the sea becomes a little cool from July to October, when the water temperature drops to 72 °F.
Sea temperature - Rio de Janeiro
Rio de JaneiroJanFebMarAprMayJunJulAugSepOctNovDec
Sea (°F)777979777573727272727577

Rio de Janeiro
Continuing along the coast, south-west of Rio de Janeiro, the climate begins to be rainy all year round (see Santos), but here we enter the area having a sub-tropical climate, where winter get progressively cooler (see below).
Moving to the interior, nearly 560 miles from the sea, we find the capital Brasilia, which has a pleasantly warm climate all year round, due to the altitude, in fact the city is located about 3,300 feet above sea level. The daytime temperatures range between 77 and 83 °F throughout the year; the minima at night are more variable, and they are higher from October to March, while they become cooler in winter. At times, from May to August, short outbreaks of cold air coming from the south can lower the night temperature around or even below 41 °F.
Average temperatures - Brasilia
Min (°F)636364635955555961636464
Max (°F)818181817977778182828179

The rainy season runs from October to April, and in particular the period from November to February is very rainy. The best period is the winter, from May to August, which is dry and sunny.
Here is the average precipitation.
Average precipitation - Brasilia
Prec. (in)

In Goiania, we find a similar climate, being located at 2,460 feet above sea level, and at no great distance from the capital; here, however, the temperature is slightly higher, and from September to April it can be a little hot. Even Belo Horizonte has a similar climate, since it is located at 2,800 feet above sea level, but its southern location makes it a bit cooler in winter, averaging around 68 °F in June and July.
At lower altitudes, it's hot in inland areas: for example, in Cuiabá, Mato Grosso, the temperatures can reach 105 °F from August to October, ie in spring, before the rainy season.
South of Cuiabá we find the Pantanal, a vast wetland area, with a large biodiversity.
About 215 miles away from the coast, north-east of Natal, lies the Fernando de Noronha archipelago: here it's hot and muggy throughout the year, with a rainy season from February to July, and a dry season from August to January.

Area with a subtropical climate
The southernmost part of Brazil (known as "South Region", composed by the states of Paraná, Santa Catarina and Rio Grande do Sul) has a subtropical climate, with winter temperatures that recalls the Mediterranean climate. Rainfall is well distributed throughout the year: in winter it's more common and abundant than in regions having a tropical climate, though typically not too heavy, but it rains also in summer, so we cannot properly speak of Mediterranean climate.
The megalopolis of São Paulo, which is located north of this area, at 2,600 feet above sea level, is in the boundary between the tropical and subtropical climate: its average temperature ranges from 73.5 °F in January and February, to 62 °F in June and July. The rainy season runs from October to March, so the best time to visit this city goes from April to September. The period from June to August, as well as being the coolest, it's the least rainy overall. Here is the average precipitation.
Average precipitation - Sao Paulo
Sao PauloJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (in)

From May to September, sometimes at night the temperature can approach freezing, while from September to March it can sometimes be hot, around 91/95 °F. São Paulo has generally pleasant temperatures, but it is a polluted city, and it's often surrounded by a pall of smog that can obscure the sun.
Average temperatures - Sao Paulo
Sao PauloJanFebMarAprMayJunJulAugSepOctNovDec
Min (°F)666664615754545557596364
Max (°F)818281777372727375777979

Further south, in Curitiba, in the state of Paraná, 3,000 feet above sea level, winter is cooler, so that the average in June and July is 55.5 °F. Sometimes at night the temperature can drop to the freezing point, from May to September.
In Florianópolis, further south (at a latitude of 27° S) but on the coast, the average temperature goes from 63 °F from June to August, to 77 °F in February.
Average temperatures - Florianópolis
Min (°F)707270646155555759636668
Max (°F)828282777370687070737781

As mentioned, precipitation in the south is quite common even in winter. In Florianópolis, 60 in of rain per year fall, with a maximum in summer and autumn, from September to March, but with nine days of rain and no less than 3 inches per month even in winter. Here is the average precipitation.
Average precipitation - Florianópolis
Prec. (in)

In Florianópolis, the sea is a bit cold in winter, while it becomes warm enough for swimming from November to April, and particularly warm from January to March.
Sea temperature - Florianópolis
Sea (°F)797979757268666668707375

Further south, in Porto Alegre, in the state of Rio Grande do Sul, the average temperature goes from 59 °F in June and July, to 76 °F in February: therefore, summer is still hot (indeed, it is a bit warmer than in Florianópolis, given the distance from the sea), but winter is a bit cooler.
At this latitude, where summer thunderstorms are a little less frequent, while the winter disturbances pass more often, winter becomes even the wettest season, though not by much, as you can see from the average rainfall of Porto Alegre.
Average precipitation - Porto Alegre
Porto AlegreJanFebMarAprMayJunJulAugSepOctNovDecYear
Prec. (in)

In the southernmost part of Brazil, in winter the nighttime temperatures can reach 32 °F even in the plains.
In Rio Grande, at a latitude of 32° S, the average July temperature drops to 55.5 °F.
Average temperatures - Rio Grande
Rio GrandeJanFebMarAprMayJunJulAugSepOctNovDec
Min (°F)686866595552505054576164
Max (°F)828179736864616366707379

In Rio Grande, even the temperature of the sea is similar to that of the Mediterranean, and becomes warm enough for swimming only in summer, while in winter it is cold.
Sea temperature - Rio Grande
Rio GrandeJanFebMarAprMayJunJulAugSepOctNovDec
Sea (°F)737573706461575759636672

In inland areas, in cities located at higher altitudes like Lages (3,100 feet) or Sao Joaquim (4,250 feet), at times even snowfall can occur from June to August.
In the southern tip of the Rio Grande do Sul, the winter averages reach 52/54 °F.
In the Iguaçu Falls, on the border with Argentina and Paraguay, the average in July is 59 °F, and the rains are frequent throughout the year, with a relative minimum in July and August. Summer, from December to March, is hot and muggy, with sunshine and thunderstorms.

When to go

Wanting to find a single period to visit Brazil, you can choose the austral winter, ie from June to August, being usually the coolest, the least rainy and the sunniest period. In the far south, however, winter is rainy, and sometimes it can get cold; as regards the rain, as we have seen there are exceptions even in the north-central, which relate mainly to coastal areas, so for the individual zones you can refer to the foregoing sections.
As we have seen, the sea is warm enough all year round for swimming in north-central Brazil, while it becomes relatively cool from June to October at Rio de Janeiro, and even cold along the coast of Rio Grande do Sul, where it drops to 57 °F in August. Here the sea temperature becomes acceptable, around 73/75 °F from January to March.

What to pack

In winter (June to August): in the Amazon, tropics-friendly, loose fitting clothing, maybe with long sleeves for mosquitoes; a sweatshirt for the evening. In the north-east, from Natal to the south, light clothing, a sweatshirt for the evening, a light scarf for the sea breeze, a light sweatshirt and a light raincoat for thunderstorms; a light scarf and a light sweater for the evening also in Sao Luis and Fortaleza, on windy evenings. In Rio de Janeiro, light clothes for the day, a sweatshirt or sweater and a jacket for the evening, raincoat and umbrella. In Brasilia, Sao Paulo, Florianopolis and the extreme south: clothes for spring and autumn, sweater, jacket, raincoat or umbrella.
In summer (December to February): In the forest and the tropical region, up to Rio de Janeiro: tropics-friendly, lightweight clothing, possibly a light sweater and a light raincoat for thunderstorms, sun hat, possibly sweater and scarf for air-conditioned places. In Brasilia, Sao Paulo and the south: light clothes, a sweatshirt and a light jacket for the evening, raincoat or umbrella.