It is already dark in the New Delhi suburb of Noida on a night in December when I arrive at the home of one of the biggest YouTube stars in all of India. Yet the person who greets me at the door defies every stereotype the word YouTuber evokes. Nisha Madhulika is a 60-year-old grandmother dressed in a long robe and sandals, with her hair tied in a ponytail. After settling me in an armchair in the living room, she plies me with home-baked cookies. “You must try them,” she says, in a voice barely above a whisper, using her son to translate from Hindi.

Given the transformation unfolding in India, it seems fitting that Madhulika, with 6.5 million subscribers to her YouTube cooking channel and 200,000 more signing on each month, has hit it big late in life and with little forewarning. That, in a nutshell, could just as well describe India’s belated embrace of all things digital. Hundreds of millions of Indians have logged on to the Internet for the first time in the past two years. The surge is owing to aggressive government policies aimed at connecting Indians online and plummeting prices for data and smartphones. About 390 million Indians are now active Internet users, almost a third of the population and twice as many as were connected in 2016, according to industry estimates. For context, that’s more Indian Internet users than all the people who live in the United States.

A generation ago, the U.S., Europe, and then China added similarly huge numbers of people to the Internet. Yet the process in those areas was steady and gradual, moving from dial-up modems through clunky Wi-Fi to mobile tech. Contrast that with India, where hundreds of millions of people have skipped the early-stage Internet altogether; many have never even touched a computer. Instead, they have started online by downloading apps and watching mobile-phone videos at a furious rate. Since 2017, Indians have begun downloading more apps than Americans do. And last year, India became the biggest consumer of mobile data on Android phones. “We have not seen this kind of user behavior anywhere else in the world,” says Rajan Anandan, vice president for India and Southeast Asia for Google, the purveyor of Android mobile-phone software. Google also owns YouTube, which started the phenomenon of user-generated video in Silicon Valley more than a decade ago and now has 245 million Indian users. “This is perhaps the world’s first video-first digital economy,” he says.

Passengers at the Kochi railway station, one of many at which Google installed free Wi-Fi.

Photograph by Vivek Singh for Fortune

For Western companies vying to increase their slice of global markets, India’s steep digital trajectory has proved a strong draw. Perhaps no company embodies the huge hurdles of ramping up in India, and the huge payoff it might bring, as much as Google. The company’s growth depends on finding ever more users, as advertising drives more than 80% of its profits. Given that Google and other Western giants essentially are shut out of China, no other country offers a bigger opportunity to add hundreds of millions of consumers than India. “This is one of the largest populations in the world, with an income base that is a lot lower than elsewhere, so it is challenging,” says Brent Thill, an analyst in San Francisco with investment bank Jefferies. Still, he says, with more than $100 billion in cash, Google can spend years creating its India business without fretting over the cost. “They have an incredible asset base to use to go after that population,” Thill says.

That much was plain when I crisscrossed the country late last year, from remote villages to the vast urban sprawl of Mumbai and New Delhi, to see how Google was building its infrastructure in India, as well as how the country has become a crucial testing lab for the company. The process of scaling up Google’s India business is in full swing. But it will be both long and costly. Google declines to quantify its investment in India. “It is a lot,” says Anandan, the region’s top executive. “It is an investment we are going to make for the next 10 to 15 years, to really get people online,” he says, adding that true profitability “is long term.” Google also won’t describe the size of its business in India, but analysts peg annual revenue at $1.3 billion, a paltry portion of the company’s $136 billion in 2018 revenues.

The impact of Google’s work in India, nonetheless, is being felt not only in India but also far beyond, including more than 7,000 miles away, at the company’s headquarters in Mountain View, Calif. Increasingly, India is becoming the blueprint for Google’s eventual push into dozens of other emerging markets, where poverty, illiteracy, and costly but slow service have kept most people off the Internet. These include some of the world’s fastest-growing economies, like Indonesia, with 260 million people, and Nigeria, whose population is on track to overtake that of the U.S. by 2050. “We are thinking of products from scratch,” says Josh Woodward, director of product management for Google’s “next billion users” team, which the company formed in 2015 to focus on new markets. “If you were to build a product for Mumbai and not Mountain View, what would you build?” asks Woodward, illustrating the unit’s approach, which it expects to evolve over “generations.”

Google’s executives likely will not be around to see how that question is answered. They also know there is genuine good to be done—and a ton of money to be made—by the companies that figure out how to bring Internet service to the vast numbers who still don’t have it. “The big question is, What does it take to get them connected?” asks Google’s Anandan. “India absolutely will tell us a lot about what it really takes.”

Google has been operating in India for years, having opened its first non-U.S. R&D center in Bangalore in 2004. But its push to expand in the country is now exquisitely well timed. The pro-business Prime Minister Narendra Modi has made a digital revolution the centerpiece of his government. And some Indian conglomerates have been answering his call. Modi campaigned for office in 2014 on a promise of getting all Indians online. Then in 2016 he invalidated most of India’s paper currency in circulation at the time, effectively pushing millions onto digital payment systems. The government also put public services like health insurance online, and it introduced a national sales tax in 2016 that required businesses to file digital records. A national ID card now collects biometric data on every citizen.

India’s digital policies have seemed dictatorial at times, and for many poorer Indians, they have been painful. But officials insist desperate measures are essential to improve an overwhelmingly cash economy, where most people pay no taxes. About a million Indians enter the job market every month, yet most people still live in rural villages, with few opportunities. “More than physical infrastructure, we need digital infrastructure if we are to grow at 9% or 10% a year,” says Amitabh Kant, CEO of the government’s National Institution for Transforming India, or NITI Aayog, which spearheads India’s digital strategy. “If we were to go around building physical banks and physical schools, and hiring bank managers, it would take us hundreds of years,” Kant says, sitting in his New Delhi office. Outside, the lobby features a statue of national hero Mahatma Gandhi meditating in a sarong, with rose petals at his feet—a subtle reminder that India’s digital policies are for the good of the nation. “China took 30 years to lift the vast segment of its population above the poverty line. America took close to 100 years,” says Kant. “The only way India can do this in the next 15 years is to digitally leapfrog.”

That leapfrogging might have sputtered on takeoff had it not been for a decision taken by one giant Indian company, the country’s biggest conglomerate, Reliance Industries. In 2011, Reliance, whose core business was oil and infrastructure, decided to build a vast broadband network, a business in which it had no experience but plenty of rivals. It had acquired a telecom company that owned mobile spectrum licenses, and it muscled in on its competitors. Barely 28 million Indians then owned smartphones. Reliance aimed to blanket India with broadband coverage, which was available only in big cities. After decades building pipelines and refineries, Reliance erected 220,000 mobile towers across India, often building more than 700 in a single day. In all, the project cost more than $30 billion.

In September 2016 it launched the Reliance Jio telecom network, offering people free mobile…