So Brazil's presidential elections during the Fourth Republic (otherwise known as the Populist Republic) were a bit of a mess. In 1945, the armed forces overthrew Getúlio Vargas and proclaimed free elections, in which Army general Eurico Gaspar Dutra and Air Force brigadier Eduardo Gomes stood as the main candidates. Dutra was supported by Vargas from behind the scenes, and endorsed by the PSD, which was essentially a formalised national organisation for the various Getulist political machines in the different states. This superior organisation turned out good enough to put Dutra in the presidential palace, and to give his allies in the PSD a majority in the Congress.
Dutra's main achievement in office was the 1946 constitution, which maintained a system of government styled after the US, but with direct elections for President and Vice President (the latter on a separate ballot, which accounts for about half of the confusingness of the period) and the Chamber of Deputies elected by PR. The new constitution also gave women the vote, which they'd technically already had under Vargas, except that all suffrage under Vargas was a bit "lol".
With the tyrant Getúlio Vargas having been overthrown, democracy inaugurated in Brazil and the country's first democratically-elected president in twenty years (or possibly
ever, depending on what you count as "democratically elected") served out his term in peace, the first regular presidential and vice-presidential elections were held in December 1950, returning a comfortable majority result in support of centre-left populist candidate (
checks notes) Getúlio Vargas. His main opponent was Eduardo Gomes, who repeated his effort from five years before, and this time had an organised broad anti-Getulist party, the National Democratic Union (UDN) behind him. This would in time shed whatever tiny left-wing factions it once had to become Brazil's major right-wing conservative party.
Vargas actually did alright as a constitutional head of state, kind of. He pursued economic nationalism, very similar to that of Juan Perón over in Argentina, and famously nationalised the petroleum industry in 1952 creating Petrobras, now notorious as one of the most corrupt institutions in the Western world. By 1954, though, he was on thin ice after his head of security was accused of putting out a hit on one of his political rivals. The armed forces again called for his removal from office, and Vargas decided to shoot himself in the head rather than give them the satisfaction of capturing him alive.
The 1955 elections went off without a hitch though, which is honestly kind of striking, and the right-Getulist PSD formed an alliance with the left-Getulist PTB to nominate Juscelino Kubitschek, a rural doctor from the backcountry of Minas Gerais, for president with João "Jango" Goulart, a rural lawyer from Rio Grande do Sul who'd been a protégé of Vargas (they were both from the same town) and who had made himself a hero of the working classes as Vargas' Minister of Labour, for vice-president. The ticket won a fairly comfortable victory in a three-way race with the UDN and the PSP of Adhemar de Barrios, the fabulously corrupt but politically savvy former governor of São Paulo.
Kubitschek had the most successful presidency of the entire period - for one thing, he managed to serve his full five years without either getting forced out of office or killing himself. He's probably most well-remembered for beginning construction on Brasília, a new capital way out in the backcountry of Goiás (coincidentally not far from where Kubitschek grew up over in Minas), but he also initiated loads and loads of other development projects, possibly pocketing quite a bit of money for himself in the process or possibly not. It was, however, enough to make him a target of anti-corruption populists.
One such man was Jânio Quadros, the eccentric former governor of São Paulo (notice a pattern here?), who had a reputation for wearing dishevelled clothes, eating mortadella sandwiches (a popular Paulista street food) during his public appearances, and waving around a broom to symbolise his promise to sweep out corruption. His nomination was supported by the UDN, which could find no credible candidate of its own after three consecutive losses, while the PSD nominated Field Marshal Henrique Teixeira Lott, who'd been one of Kubitschek's most trusted advisers.
The 1960 election is the most confusing of the era, because while Quadros handily defeated Lott for President, the vice-presidential ballot looked very different. There was a large working-class movement that called for a "Jan-Jan" (Jânio-Jango) vote, and they were successful enough to ensure that Goulart was returned as Vice President for a second term even as his running mate went down in flames. As such, the most left-wing candidate had won in both races, and the conservative establishment was inevitably going to sit up and take notice.
Quadros, while a successful state governor, quickly turned out to be way beyond his depth as President. He resigned in August 1961, citing "terrible occult forces" working against him - this might or might not have been a bluff intended to boost his popularity, but the Congress called the bluff and allowed him to resign. This passed the presidency to João Goulart - Goulart, who had spent his entire term as vice-president championing social reforms in the Senate and building relations with the Communist bloc, and who was right now, at this very moment, on a state visit to the People's Republic of China. The right-wingers in the Congress initially wanted to physically prevent Goulart from assuming office, but a compromise was reached where Goulart would be allowed to take power, but not before constitutional amendments had been passed turning Brazil into a parliamentary republic with a Prime Minister who handled just about all actual policy-making.
Goulart was able to strengthen his hand once in office though, and in 1963, he called a plebiscite to confirm the amendments. They were rejected by over 80% of voters, and were nullified, allowing Goulart to assume the sum of executive power. He immediately set about on an enormous reform programme, creating a state electric company, redistributing land to rural peasants, and massively expanding public education with the goal of eradicating illiteracy (additionally important because the 1946 constitution made literacy a requirement for voting). This was to be funded by a big corporation tax hike, which obviously didn't play great with the sort of right-wing establishment types who already basically thought Goulart was a crypto-Communist. It also didn't play well with the United States, which was famously quite jumpy around any Latin American leader who might be construed as somewhere to the left of Attila the Hun.
On 31 March 1964, tanks rolled out into the streets of Rio de Janeiro. Goulart was kicked out of the city, tried to make a stand in Brasília, but ultimately fled to Uruguay as the Congress passed a resolution deposing him from office. The Congress then elected Field Marshal Humberto Castello Branco, Chief of Staff of the Brazilian Army, to the presidency for the remainder of Goulart's term (well, Quadros' term, really) - he promised to uphold Brazilian democracy and do his utmost to combat abuses of power. Which, er,
yeah.