Larry Atencio is steering his Ford Explorer through the streets of Pueblo, Colo., pointing out how the city is going green.

There’s the site of a planned community solar garden in an up-and-coming neighborhood, a manufacturing plant for wind turbines that opened in 2010 and the largest solar farm in Colorado, an array of 450,000 panels on 900 acres. Atencio, a small-business man who for years made and sold his own candy and now serves on the city council, has spent years trying to turn this industrial town on the Front Range into a hub for green-energy projects. “Pueblo is becoming quite the renewable-energy city,” he says with a grin.

It’s all part of a deliberate, idealistic plan. In February 2017, just a month after President Trump took office, the city council approved a resolution committing Pueblo to power itself on 100% clean energy by 2035. Local leaders heralded the push as a way to lower energy bills, grow the local economy and reduce the city’s climate footprint.

But over the past year and a half, Atencio and his colleagues have found that going green is easier said than done. To meet its goal of 100% clean energy, Pueblo will need to overcome a raft of technical, financial and legal challenges. In all likelihood, the city will need to extricate itself from a 20-year contract with the electric utility that built Pueblo a new natural gas plant. Then it will have to develop a new stream of clean energy. All without passing on costs to already angry taxpayers and energy users, who pay some of the highest electricity rates in the region.

Pueblo is not the only city grappling with these challenges. As the Trump Administration doubles down on fossil fuels, some 70 U.S. cities, from St. Louis to San Francisco, Orlando to Aspen, have committed to powering themselves with 100% clean energy, according to the Sierra Club, which is organizing a campaign around the pledge. Hundreds more have set their own targets to go green. “You’re beginning to see mayors and governors filling this gap,” says Carter Roberts, president of the World Wildlife Fund.

The stakes are high not only for Pueblo but for the planet. The bulk of the nation’s electricity flows through cities, and by acting together to embrace renewable energy, the greening cities hope to achieve two important goals: counteract Trump’s climate positions, which include pulling out of the Paris Agreement, overturning climate regulations and subsidizing coal; and create new demand for U.S. wind- and solar-energy production, which now accounts for less than 8% of the country’s electricity.

Some cities may incur only modest costs or even save money from going renewable, according to analyses prepared for different cities and utilities, making the decision an easy call. Elsewhere, the expense may collide with the enthusiasm for going green. Pueblo may be headed on such a collision course, and success is by no means guaranteed: ultimately, the same city council that set the idealistic goals may choose to bail on them. “Can we get there by our deadline?” asks county commissioner Terry Hart, a key advocate of going renewable. “Don’t know. We’re going to try.” But if Pueblo can figure out the puzzle, so can others.

Workers build wind turbines at the Vestas factory, part of an emerging green economy in Pueblo Jamie Kripke for TIME

The first reason it’s hard to go green is that most cities don’t actually have much control over their power sources. Two-thirds of Americans get their electricity from investor-owned utilities, or IOUs. These companies typically have monopolies in their service territory, protected by contracts that can stretch for decades.

Pueblo (pop. 106,000) is a case in point. In 2010 the city, once dubbed the Pittsburgh of the West, renegotiated its deal for South Dakota–based Black Hills Energy to provide it power. To do that, the company built a brand-new natural gas plant. The facility, which opened in 2012 as the Pueblo Airport Generating Station, occupies a small footprint on the outskirts of town and employs just 20 people, but it can produce nearly enough electricity to power all of Pueblo.

The new power plant has come at a steep cost. Black Hills shelled out nearly $500 million to build the facility, a price tag that the company has passed on to consumers via higher electricity rates. As a result, today Pueblo residents face some of the highest electricity bills in the region. Black Hills has tried to mollify angry locals, reducing reconnection fees for struggling residents and supporting a small-scale solar project in a low-income neighborhood. “I want to earn the business of the customers we serve,” says Vance Crocker, vice president of Black Hills operations in Southern Colorado, a mild-mannered engineer brought in to repair the relationship between the company and the community.

But as long as Black Hills is in the picture, Pueblo’s push to go fully green may be impossible. That’s because residents will need to pay for the natural gas plant in addition to any new renewable-energy projects. So city leaders in Pueblo are trying to exit their 20-year contract with the company early, using a clause in the agreement with Black Hills that gives the city an opportunity to dump the utility 10 years after signing, in this case in 2020. The process would require the city to condemn Black Hills’ assets, force the company to hand over its local infrastructure and potentially form its own nonprofit utility.

Ditching the contract midway through is an extreme step, one that Black Hills has acknowledged in SEC filings as a threat to its business. But the most committed locals say it’s the only viable way to meet their goal. “There’s no room for concessions,” says Sue Perkins, an energy lawyer working with Pueblo renewable advocates.

The second reason going green is so difficult is the cost. Renewable-energy advocates rave about how cheap renewables have become. Indeed, in many parts of the country, generating electricity from renewable energy can cost less than from coal or even natural gas. That’s especially true in southern Colorado, a region the National Energy Renewable Laboratory says is home to some of the country’s best land for solar power.

But those calculations omit a key variable: someone still needs to pay for the existing fossil-fuel infrastructure. While renewable energy may be cheaper than fossil fuels when a utility starts from scratch or replaces old power plants that have reached the end of their usable life, overhauling the existing electricity system is much more complicated and costly.

This is particularly true in a place like Pueblo. When the city nixes its contract with Black Hills, it will lose the $3.4 million the energy company pays annually into the city’s coffers for the privilege of doing business there. At the same time, Pueblo will need to pay Black Hills in order to take over its assets. That includes not only neighborhood power lines and substations but also, most likely, the much maligned natural gas plant. If Pueblo and Black Hills can’t agree on a price, state regulators would step in or the matter would be litigated in court.

After that, Pueblo would still need to figure out how to supply the city with renewable energy, which comes with its own set of challenges. Will officials try to build their own power plants? Buy renewable energy from someone else? Or keep powering the city with fossil fuels while purchasing credits that support renewable energy elsewhere? All this will require a team of lawyers, engineers and consultants.

Cities that have tried to set up their own utility know how expensive the process can be. Eight years ago, just 150 miles up Interstate 25, the city of Boulder refused to renew its long-term contract with Minnesota-based Xcel Energy because the electric utility refused to go along with Boulder’s climate plan, a city program designed to reduce its contribution to climate change. Instead, Boulder opted to go through the process of setting up its own municipal utility.

Since then, Boulder has lost tens of millions of dollars in revenue that Xcel would have paid for renewing the contract and shouldered millions more in legal fees and other costs. Residents made up for the lost revenue directly with a voter-approved tax hike in 2011 that was extended last year. “Do we want to be in the business of running an electric utility? No,” says Jonathan Koehn, Boulder’s regional sustainability coordinator. “But it allows us to live up to the values of this community.”

It’s not clear just how much going 100% green would cost Pueblo. Advocates of going renewable say the savings from nixing corporate expenses–including dividends to shareholders and executive compensation–can help make up for the costs. In April, city officials launched a search for a consultant to assess the economic feasibility of leaving Black Hills and are currently evaluating proposals.

Even the slightest spike in prices may be higher than residents can bear in a blue collar city where nearly 25% of residents live below the poverty level. Which is why even more than the legal hurdles of separating from Black Hills or the technical challenge of setting up its own power supply, the future of Pueblo’s energy may depend on politics and whether local leaders can persuade their constituents to stick with their plans.

That may be the hardest hurdle of all. On a Tuesday in May, members of the city’s electric utility commission met to discuss splitting from Black Hills. Under questioning, even proponents of going 100% renewable acknowledged it may not be in the cards if it means Pueblo’s residents can’t afford it. “The economics is really the driving factor,” said Hart, the county commissioner. “The environmental factors are important, but they fall behind economics.”

With all its struggles, Pueblo represents a particularly challenging case, and other cities may find it easier to go green. “No two cities will get there in the same way,” says Jodie Van Horn, who runs the Sierra Club’s campaign to push cities to go renewable. That means a wide range of strategies and, perhaps more important, costs that vary from city to city.

A defunct power plant, once operated by Black Hills Energy, looms over Pueblo’s Riverwalk Jamie Kripke for TIME

In Atlanta, officials have identified aggressively encouraging rooftop solar panels and reductions in residential energy consumption as likely avenues. The city may purchase credits to make up the difference. A report commissioned for Salt Lake City, which Mayor Jackie Biskupski says has a “great” relationship with the local utility, shows how the Utah capital and its neighbors could support the construction of new renewable plants and purchase entirely clean electricity with only “modestly higher” costs. “People are more than willing to pay,” says Biskupski.

Some smaller municipalities, such as Rock Port, Mo., and Georgetown, Texas, have already met their 100% renewable goal, largely because of their locations in the center of renewable-rich territory. And the path to success can be smoother in the roughly one-third of the U.S. that is not bound to an IOU. Municipal-owned utilities and co-ops provide power free from many of the state rules that often make local energy policy difficult for local leaders to manage. In cities with municipal utilities, in places ranging from small towns in the Midwest to large urban areas like Orlando, city councils often have direct authority over electricity contracts and appoint regulators.

The situation is more complicated elsewhere and potentially prohibitively expensive. In some cities, the best option to try to fulfill a clean-energy commitment may require pushing the state legislature for pro-renewable reforms or applying local taxes as a lever, according to a May 2017 report from the Meister Consultants Group, an energy-advisory firm.

Despite the challenge, the push may pay big dividends for the world if enough places stick with it. Trump has reversed many of the federal policies underpinning the U.S. commitment to deal with global warming, seeking to incentivize coal production even as market factors have driven rapid-fire growth in renewables. In this environment, cities and states can move the needle even if they don’t go green entirely. A June report from the Rhodium Group estimated that U.S. greenhouse-gas emissions will fall by up to 20% by 2025, in part thanks to the momentum created by city and state policies supporting renewables. (Growth in natural gas use, which emits less than coal but more than renewables, also contributes to the trend.) That’s short of the Obama-era target of at least 26%, but climate advocates hope it’s enough to keep the momentum going. “Because of that demand, we’re seeing price forecasts for renewable technology coming down,” says Kate Larsen, a director at Rhodium.

That’s why some proponents of going green in Pueblo say getting to 80% or 90% would still be a success. “Eighty percent is a whole lot different than 100%,” says Steve Andrews, a Pueblo-based energy consultant. “But it gets you 80% of the way there.”

And that can make a big difference. In Boulder and Denver, which both get their electricity from Xcel Energy, aggressive campaigns to go green helped push Xcel to announce in June that it would spend $2.5 billion to build a slew of new renewable-energy plants, making renewable generation 55% of the company’s electricity mix in the state by 2026. Because renewable energy will replace old inefficient fossil-fuel plants, Xcel expects that the move will ultimately save consumers $215 million a year. It’s a step in the right direction, even if it’s not enough to satisfy renewable-energy advocates. “The goal is the goal,” says Boulder’s Koehn. “When they put someone on the moon, they didn’t say let’s go 80% of the way there.”

The moonshot resulted from the vision of President John F. Kennedy, who inspired thousands of federal employees and pushed the U.S. to invest more than $100 billion in today’s money in the Apollo program. Today, American cities committed to going renewable will have to generate their own inspiration.

This appears in the July 23, 2018 issue of TIME.

Get The Brief. Sign up to receive the top stories you need to know right now. Please enter a valid email address. Sign Up Now Check the box if you do not wish to receive promotional offers via email from TIME. You can unsubscribe at any time. By signing up you are agreeing to our Terms of Use and Privacy Policy . This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply. Thank you! For your security, we've sent a confirmation email to the address you entered. Click the link to confirm your subscription and begin receiving our newsletters. If you don't get the confirmation within 10 minutes, please check your spam folder.

Write to Justin Worland at justin.worland@time.com.