Brazil’s been in the news lately, and not always for the most positive reasons. Amidst news of recession, resulting austerity measures, and a successive series of large-scale corruption scandals, the developments from this previously booming emerging market seem grim.

But as an emerging-markets expert, I’ve been watching Brazil very closely, and it’s clear there is a bright spot in all this doom-and-gloom coverage. Brazilian cities consistently make top 10 lists for digital entrepreneurs — as I’ve previously written. In fact, I would go so far as to say that no list of emerging startup cities would be complete without a mention of Brazil’s Sao Paulo, which is a fantastic startup environment.

The evidence for this tech renaissance is plain as day: Multinational and regional tech powerhouses have graced Brazilian cities with their approval. For instance, Google, Airbnb, and Uber have built offices in Sao Paulo; in Google’s case, its Sao Paulo campus is a cross between a coworking space, accelerator, and networking center – a sort of comprehensive, all-inclusive startup factory.

Yet this strength in technology stems from a series of complex, sometimes contradictory factors. Seen from above, Brazil’s tech scene is undoubtedly impressive — a marked contrast to other ailing sectors of the nation’s economy. Upon closer look, however, the nation splits into a varied, patchwork landscape of scrappy entrepreneurs, motivated techies, and government officials who alternate between supportive intervention and bureaucratic sluggishness.

In short: It’s complicated.

The mixed role of government

Brazil is infamous for its bureaucracy. A 2015 study by the World Bank estimated that Brazilian businesses spent a staggering 2,600 hours on filing taxes — some three times more than Venezuela (not exactly known for its streamlined government), and 15 times the average in European countries. In a similar vein, Brazilian companies spent 15 more days to export a product than most other nations. For all this hassle, Brazil ranks 123 of 190 nations in the World Bank’s Ease of Doing Business Database, though there have been some minor improvements in areas like contracts, property registration, and cross-border trade.

Yet in spite of this bureaucratic stagnation, Brazilian states are taking the initiative, competing with one another to provide the best incentives and attract the most entrepreneurs. Artur Sousa, founder of Adopets, a digital animal adoption platform, notes that improvements in business regulation are often driven by individual Brazilian states, rather than the federal government at large.

“States like Minas Gerais have developed incubation programs,” Sousa explains, citing MG’s Seed program. Created by the state government in 2013, Seed is a six-month program that is equal parts accelerator, startup ecosystem, coworking space, and angel investor (albeit without the equity requirement). In fact, Minas Digital, the state’s digital development authority, isn’t alone: similar programs exist around the country, from Sao Paulo to smaller cities like Porto Alegre and Recife.

People power

So what gives? On the one hand, strategic government intervention has spawned a thriving tech ecosystem, home to a rich range of venture capital firms, incubators, and a deep, vibrant community of talented founders and workers. On the other hand, government red tape remains a very real hindrance to entrepreneurs, with lingering problems in several areas of business, especially taxes. If anything, solutions seem piecemeal — invite entrepreneurs to the city, build incubators, and offer funding — and don’t necessarily address the deep-rooted dysfunction of business legislation.

One reason for the tech sector’s success in pushing back against bureaucracy is its human capital, specifically the well-organized, welcoming entrepreneurial ecosystems. In Sousa’s view, digital workers, founders, and investors drove the change, taking matters into their own hands rather than waiting for the government to catch up.

“To be an entrepreneur in a country like Brazil is inherently an act of resilience,” Sousa says. Though judging by his words, Brazilian entrepreneurialism is also a crash course in autonomy and taking initiative. “We did not have incentives or community. … Entrepreneurs got together, made things happen, attracted interest, and from there, started building out the ecosystem from the inside out.”

All this is to say that success brings with it a sort of power and influence. And in an otherwise dismal economic landscape, few sectors are more successful than startups. From 2011-2016, Brazil’s startup sector was estimated to have grown by 30 percent per year, even as the rest of the country deals with political crises and an unemployment rate of 13.6 percent (or 14 million people). Overall recovery has also been slow: While the S&P Global believes Brazil has stabilized, the economy is only expected to grow at around two percent through 2017.

In contrast, the impact of these feisty, never-give-up entrepreneurs is plain as day, attracting investment and collaboration from sources near and far, though many of the most significant projects are entirely (or largely) private ventures. For instance, Brazil’s largest bank, Sao Paulo-based entrepreneurs, and California-based VC firm Redpoint e.ventures joined together to launch Cubo, a massive, 50,000 square foot coworking space. In addition, venture capital is also on the rise. Softbank also invested $100 million in 99, a Brazilian ride-sharing company. At the same time, Argentina-based Kaszek Ventures created a $200 million fund in May 2017, alongside other stalwarts of capital like Sequoia, the Pennsylvania-based Dietrich Foundation, and Accel.

Tech has also made more of an impact in some cities than others. For instance, Sao Paulo is ranked 12th for startup innovation worldwide, home to more than 2,700 active startups. More impressively, Sao Paulo’s startup scene has weathered the latest political and social upheavals very successfully, from a harsh austerity program to a presidential impeachment.

According to one State Department report, the continued strong performance of the technology sector may be related to the recession: Brazil, famous for high prices even before the recession, has seen costs skyrocket because of a weaker dollar. As a result, consumers are increasingly turning to e-commerce, which offers lower prices and more convenient experiences than brick-and-mortar retailers.

If anything, tech (and mobile apps in particular) is poised to continue its dominance of the Brazilian economy. After all, smartphones are widespread: In 2015, there were an estimated 89.5 million smartphone users throughout the country out of a total population of 200 million. Despite taking heavy losses during the 2016 recession, the smartphone market is in the middle of a strong recovery and is projected to grow further, fueled primarily by inexpensive (under $100) LTE-enabled devices.

Ultimately, when it comes to startups, Brazil is a dynamic, people-powered paradox. Even as tech is the nation’s most profitable, best-resourced sector, it is successful despite some fairly significant obstacles. In fact, tech may well be Brazil’s last, and best, hope.

Ping Jiang is an investor specializing in emerging markets and undervalued investment vehicles. As part of his specialization, he often writes on trends in emerging markets, from technology to infrastructure.