A new president took office this month determined to fight climate change. Wall Street investors think Tesla is worth more than General Motors, Toyota, Volkswagen and Ford put together. And China, the world’s biggest car market, recently ordered that most new cars be powered by electricity in just 15 years. Those large forces help explain the decision by G.M.’s chief executive, Mary T. Barra, that the company will aim to sell only zero-emission cars and trucks by 2035.

Her announcement, just a day after President Biden signed an executive order on climate change, blindsided rivals who usually seek to present a united message on emissions and other policy issues. But it was also years in the making. G.M. has had a love-hate relationship with electric cars going back decades, but under Ms. Barra, who took over in 2014, it has inched its way toward a full embrace of the technology.

She has also shown a penchant for making big moves that her predecessors might have considered brash or impulsive given the company’s reputation for deliberate — or plodding to some — decision making. When Donald J. Trump became president, she pushed him to relax Obama-era fuel economy standards that G.M. had endorsed when they were put in place. Then, after Mr. Trump lost his re-election bid in November, Ms. Barra withdrew from a lawsuit seeking to prevent California from maintaining its own high fuel standards.

A senior G.M. executive, Dane Parker, said the company was not seeking to curry favor with the new administration. Its decision, he argued, was based on a fundamental, dollars-and-cents analysis of where the auto industry is headed and the cars that it expects to become best sellers in the future.

“We are doing this to build a sustainable business,” Mr. Parker, the company’s chief sustainability officer, said in an interview on Friday. “We want to have a business in 15 years that’s a thriving business.”

G.M. has already committed to spending $27 billion to introduce 30 electric vehicle models by 2025, and is building a plant in Ohio to make batteries for those cars and trucks. Mr. Parker said the company was looking at sites for more battery plants and working on future electric models.

“To be ready for 2035, I need to build battery plants, I need to do battery development, I need to develop electric vehicles,” he said.

One key driver of that analysis: On his first day in office, Mr. Biden signed an executive order directing the Environmental Protection Agency to immediately begin developing tough new tailpipe pollution regulations, designed to rein in the nation’s largest source of planet-warming pollution. G.M.’s announcement gives powerful political momentum to that plan, signaling that the nation’s biggest automaker supports the administration’s single largest policy to fight climate change.

DEALBOOK: An examination of the major business and policy headlines and the power brokers who shape them.

Broadly, of course, the industry had been quietly gearing up for months for a possible change in the White House. Representative Debbie Dingell, Democrat of Michigan and a former G.M. executive, said in an interview, “I had been saying to all the autos: ‘When Joe Biden gets elected, your world will turn upside down. You’ve got to be at the table or else this thing gets jammed down your throat.’”

Ms. Dingell is starting to see that effort bear fruit, as other auto companies are expected to quickly come out in support of Mr. Biden’s plans.