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.

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.”

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.

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.