DEARBORN, Mich. — Ford said Thursday that its chief executive, Alan Mulally, would retire July 1 and be succeeded by Mark Fields, a veteran executive who has played a crucial role in the company’s turnaround.

Mulally, who started at Boeing in 1969 and served as CEO of Boeing Commercial Airplanes from 2001-2006, had been expected to retire this year, ending a spectacular run as chief executive since joining Ford when it was struggling for survival in 2006.

The transition to Fields, a 25-year veteran of the company, as leader of the nation’s second-largest automaker has also been widely expected since he was elevated to chief operating officer two years ago.

Still, Mulally’s departure will end an era at Ford, in which the company borrowed billions of dollars to pay for a deep restructuring that allowed the company to avoid the bankruptcies and bailouts that overcame its chief U.S. rivals, General Motors and Chrysler.

“Alan deservedly will be long remembered for engineering one of the most successful business turnarounds in history,” said Bill Ford, the company’s executive chairman.

“Under Alan’s leadership, Ford not only survived the global economic crisis, it emerged as one of the world’s strongest auto companies.”

Mulally, 68, joined Ford from Boeing and immediately began streamlining the company by trimming vehicle programs and realigning its vast bureaucracy and regional divisions under a turnaround plan known as One Ford.

Fields played a big part in the comeback as the head of the automaker’s Americas division, which cut thousands of jobs and closed factories to better align Ford’s production with its U.S. market share.

Since becoming chief operating officer in December 2012, he has become increasingly visible in the company, running the weekly strategy meetings and overseeing Ford’s global auto operations. “Under Alan’s leadership, we have seen the power of One Ford and what a culture of positive leadership and working together can accomplish,” Fields said. “My commitment is to build on that success by accelerating our pace of progress.”

Fields will face big challenges in the coming year as the new chief executive, including overseeing the introduction of the first pickup with a body made mostly out of aluminum and continuing to pare the company’s losses in Europe.