Until recently, most of the thousands of buses on roads in the Chinese megacity of Shenzhen ran on diesel. But in 2011, long before many other cities around the world, Shenzhen rolled out its first pilot of fully electric buses. By the end of 2017, the city’s entire fleet–16,000 buses–will have shifted to electric, making it the first city in the world to reach that goal.

The scale of the endeavor makes it even more impressive. The largest bus fleet in the U.S., in New York City, has around 5,800 buses. Shenzhen has more buses than New York and the other top five bus fleets in the U.S.–in New Jersey, L.A., Chicago, and King County, Washington (home of Seattle)–combined. The city had to develop a new network of thousands of charging posts and stations and find ways to handle the cost of replacing every diesel bus.

The shift has been driven by the national and local government, which both offered subsidies that bring the high cost of electric buses in line with regular buses. (Costs are also dropping as the cost of lithium-ion batteries falls.) It’s part of a push to solve the country’s smog problem, and meet goals to cut carbon emissions. It’s also part of an effort to make China a leader in “new energy vehicle” manufacturing.

“China wants to have a strong electric bus industry, so they put in a lot of effort on the innovation and the technology,” says Xiangyi Li, a research analyst at the Ross Center for Sustainable Cities at the research organization World Resources Institute. Li visited Shenzhen and one of the city’s bus operators, Shenzhen Bus Group, to study how the system is rolling out.

One Shenzhen-based electric bus manufacturer, BYD (“Build Your Dreams”), which is also one of the largest lithium-ion battery manufacturers in the world, now sells vehicles in 50 countries. In 2016, it surpassed Tesla to become the world’s largest electric vehicle manufacturer. In Shenzhen, it produced 80% of the city’s new buses.

Without the cost of fuel, the new buses are cheaper to operate than diesel buses. They’re also cheaper to maintain. Bus operators are also experimenting with new business models to manage the cost of the shift. “Apart from the subsidy, they’re using other financial models to make it sustainable,” says Li.

Bus manufacturers, in some cases, are responsible for maintaining batteries, dealing with decommissioned diesel buses, and sometimes installing charging posts or stations, which are placed at bus depots and the first and last stops on some routes. All the players involved, from charging station manufacturers to the electric utility, met to figure out how to fairly distribute risk for quickly implementing the new technology. By 2015, there were 3,600 electric buses on city streets, and 9,000 by 2016. There are currently 15,000, and the remaining 1,000 will be in use by the end of the month. (In the entire U.S., by contrast, only 300 out of 65,000 buses are currently electric.)