Brazil’s economy has returned to pre-pandemic levels, lifted by the biggest stimulus in emerging markets and a return to normal activity by many Brazilians who have ignored scientists’ calls to remain in lockdown as Covid-19 rages across the country.

In data released Tuesday, the economy grew 1.2% from the fourth quarter, boosted by agricultural exports, taking Latin America’s biggest economy back to its size at the end of 2019 before the beginning of the pandemic. Economists had forecast growth of less than 1%.

“People were up and about, generating GDP, but at a cost to public health, as we saw from the Covid numbers,” said Alberto Ramos, an economist at Goldman Sachs. But much of the growth came from pent-up demand during the pandemic, he said, adding that the country is still struggling to diversify its economy away from commodities.

“We have to grow the hard way, which is through investment and productivity growth, and that’s a challenge for Brazil,” Mr. Ramos said.

As Brazilians fill shopping malls and bars, about 77 people are still dying from Covid-19 every hour in the country. More than 460,000 Brazilians have died from the disease so far.

Public-health experts also blame the country’s lax handling of the pandemic for creating the conditions for the emergence of the P.1 variant, which has now spread to more than 30 countries and is wreaking havoc across Latin America.

Brazil’s third consecutive quarter of growth was driven by a 5.7% rise in the country’s powerful agriculture sector from the previous three months, as well as a 4.6% rise in investments over the same period.

The Brazilian economy is expanding and shopping has picked up at stores in São Paulo.

The Brazilian economy is expanding and shopping has picked up at stores in São Paulo.

Photo: Sebastião Moreira/EPA-EFE/Shutterstock

Another reason why Brazil’s economy has bounced back so quickly is one of the world’s biggest stimulus packages. Brazil’s government spent the equivalent of 8.3% of its annual economic output last year in stimulus, most of it in cash handouts to residents of up to $233 a month, according to the International Monetary Fund.

That helped ensure that Brazil’s economy contracted just 4.1% last year, about half the size of the economic contraction in many of Brazil’s neighbors.

Brazil’s stimulus was the biggest of any major emerging market, roughly double the percentage spent by China or India and compared with just 0.7% of gross domestic product in Mexico, which saw its economy contract by a far larger 8.3% last year. The downside for Brazil is that the government piled on debt, which is now at 86.7% of GDP—a level considered unsustainable for developing countries that need to borrow.

“The aid payments were absolutely critical; without it we wouldn’t be where we are today,” said Mr. Ramos. “But was it worth it? We enjoyed a great meal, but the bill will come next,” he said, adding Brazil’s growth going forward would be slower than otherwise.

Much of Brazil eased lockdown restrictions earlier this year, preventing bigger declines in consumer spending even as the aggressive P.1 variant swept Brazil and prompted a surge in new infections.

Consumer spending declined 0.1% in the first quarter and contracted 1.7% from a year earlier, while government spending was down 0.8% from the fourth quarter and declined 4.9% from a year earlier.

“The impact of the pandemic last year was very big, and demand for credit collapsed. We haven’t seen anything similar in the lockdowns this March and April,” said Sergio Furio, chief executive officer of the Brazilian online lender, Creditas. “We’re very optimistic for 2021 and 2022, all the numbers we’re seeing point to a recovery in credit demand.”

In other parts of Latin America, countries have struggled to recover after the region’s economy contracted 7.5% in 2020, the worst downturn in two centuries, according to the United Nations.

In Peru, a strict lockdown last year caused the economy to contract 11%, the second worst contraction in South America after Venezuela. The lockdown initially resulted in the loss of about half of the jobs in Lima, Peru’s government said. With no social safety net and few savings, workers in the vast informal economy couldn’t comply with orders to stay home, making it impossible for the government to maintain a stringent lockdown.

In Argentina, the economy contracted 10% in 2020, the third biggest slide in the region, with businesses rattled by one of the world’s longest lockdowns. The IMF expects Argentina’s economy to grow 5.8% this year.

While many Brazilian informal workers had no choice but to leave home to feed their families, President Jair Bolsonaro has also encouraged Brazilians to defy lockdown restrictions by state governments, telling them late last year to “stop being a country of sissies.”

Political scientists said the country’s fast economic recovery could help increase the chances of Mr. Bolsonaro’s re-election next year, despite widespread criticism of his handling of the pandemic. He faces a challenge from the former leftist president, Luiz Inácio Lula da Silva, with polls showing a tight race.

“This was just what Bolsonaro had been hoping for,” said Rafael Cortez, a political scientist at São Paulo-based consulting firm Tendências. “His hope is that in 2022, when more people have been vaccinated, that public opinion will turn to the economy again and this will give him the edge.”

Brazil’s powerful agricultural sector also shielded the economy from the worst of the pandemic. The weak currency helped, boosting farm exports from the country, the world’s biggest producer of soybeans, coffee and sugar.

The country’s farmers grew a record crop of soybeans in the first quarter, and good commodities prices on global markets also boosted incomes. High prices on world markets for iron ore delivered another boost for Brazil, the world’s second-largest producer behind Australia.

‘Economic activity suffered a tough blow last year, but what stayed strong was commodities.’

— Pedro Paulo Silveira, chief economist at the Nova Futura brokerage in São Paulo

“Economic activity suffered a tough blow last year, but what stayed strong was commodities,” said Pedro Paulo Silveira, chief economist at the Nova Futura brokerage in São Paulo. “And world demand will stay strong for those things, so that will help growth here for the rest of this year, too.”

Before the first quarter of 2021, many of Brazil’s economic activity indicators still reflected the slump that began in the first quarter of 2020, when businesses around the country began to shut down to try to slow the spread of the coronavirus. As deaths from the disease surged further toward the middle of last year, social-distancing measures were at their strictest.

The economy began to grow again in the third quarter and that trend continued through the end of last year. But even with the strong quarter-on-quarter growth, Brazil’s GDP still contracted about 4% in 2020 from 2019.

Industry grew 0.7% in the quarter and 3.0% from a year earlier, with extractive industries including iron ore and oil production expanding 3.2% in the quarter, the statistics agency said.

The expansion in agriculture and industry more than outweighed declines in consumer and government spending. Monthly aid payments by the government to Brazil’s poorest residents starting in April of last year put money in consumers’ pockets and pushed the budget deficit higher.

That aid program ended in December of last year, and unemployment reached a record high in the first quarter, reducing families’ purchasing power.

Economists are forecasting GDP contracted in the second quarter from the first after Brazil’s state and local governments began to impose tighter social-distancing measures in March and April of this year as deaths and infections from Covid-19 began to rise again. The recovery is expected to resume in the second half of the year as Brazil’s vaccination programs slowly advance and activity picks up again.

With that outlook, some businesses are predicting strong growth for the full year and for next year.

Monthly aid payments by the government to Brazil’s poorest residents starting in April of last year put money in consumers’ pockets and pushed the budget deficit higher.

Monthly aid payments by the government to Brazil’s poorest residents starting in April of last year put money in consumers’ pockets and pushed the budget deficit higher.

Photo: Sebastião Moreira/EPA-EFE/Shutterstock

Write to Jeffrey T. Lewis at jeffrey.lewis@wsj.com and Samantha Pearson at samantha.pearson@wsj.com