SAN FRANCISCO — In 1997, Apple was on the ropes. The Silicon Valley pioneer was being decimated by Microsoft and its many partners in the personal-computer market. It had just cut a third of its workforce, and it was about 90 days from going broke, Apple’s late co-founder, Steve Jobs, later said.

On Thursday, Apple became the first public company to be worth more than $1 trillion when the price of its shares climbed to $207.05, two days after the company announced the latest in a series of remarkably profitable quarters.

Apple’s ascent from the brink of bankruptcy to the world’s most valuable company has been a business tour de force, marked by rapid innovation, a series of smash-hit products and the creation of a sophisticated, globe-spanning supply chain that keeps costs down while producing enormous volumes of cutting-edge devices.

That ascent has also been marked by controversy and tragedy. Apple’s aggressive use of outside manufacturers in China, for example, has led to criticism that it is taking advantage of poorly paid workers in other countries and robbing Americans of good manufacturing jobs.

And Jobs, admired for his dazzling product demonstrations and feared for his blunt management style, was arguably the tech industry’s most famous figure when he died in 2011 after a battle with pancreatic cancer. He was 56.

“Could anyone really imagine this back then?” said Apple’s former software chief, Avie Tevanian, who joined Apple in 1997. “We hoped to make the company very successful and very valuable. But to think it would get to where it was today? Of course not. And Steve wouldn’t have thought that either.”

Apple was founded in 1976 with the mission of making computers — then bulky, complicated industrial machines — cheap, small and simple so they could become a mass-market product. By the 1980s, the company was one of the world’s best-known brands.

But in 1985, Jobs was ousted in a boardroom coup. In the following years, the company was increasingly outgunned and outmaneuvered in the personal-computer market it helped invent.

Apple, hamstrung by a lack of new ideas, failed products and leadership turmoil, had lost its way.

Near the end of 1996, a year in which it lost $867 million, the total value of shares in Apple was less than $3 billion.

The ailing company decided to take a gamble. It bought Next, a tech firm run by Jobs, for $400 million. Jobs, still synonymous with the Apple brand, would return to the company he founded.

“It was on the rocks,” Jobs later recalled. “It was much worse than I thought.”

Jobs slashed 70 percent of Apple’s product plans, commissioned the company’s “Think Different” ad campaign, and re-imagined how it put its products together.

“We’re trying to get back to the basics,” said a weary Jobs in a 1997 internal meeting with staff. A video of the meeting posted online later showed him sporting shorts and sandals. “The question now is not can we turn around Apple. I think that’s the booby prize. I think it’s: Can we make Apple really great again?”

The focus on simplicity became a hallmark of Apple, from the way Jobs dressed — jeans and black mock turtlenecks became his uniform of sorts — to the way his products operated to the eventual look of his company’s retail stores.

In 1998, Apple introduced the iMac G3, a round, colorful, all-in-one desktop computer. It became a hit. Apple had its swagger back.

The company’s revitalization was confirmed with the iPod, the portable music player that almost immediately changed consumers’ relationship with music. The iPod, which debuted in 2001 and went on to sell more than 400 million units, showed that Apple was not just a computer company. The device was paired with iTunes, the company’s music store that would help upend the recording industry. And it portended a bigger product to come.

“The iPod was a step — a really important one,” said Ken Kocienda, a longtime Apple software engineer who will soon release a book about Apple called “Creative Selection.” “But the iPhone was really the definitive answer to the question: What comes next after personal computers?”

The iPhone transformed the way society interacts with technology, and quickly became one of the best-selling products ever: more than 1.4 billion have been sold since it was introduced in 2007.

No product or decision was remotely as instrumental to Apple’s rise to $1 trillion as the iPhone. When Jobs first announced the iPhone, Apple was worth $73.4 billion.

Former employees and analysts said that while Jobs deserves credit for overseeing the reinvention of the company’s vision and its innovation, his successor, Tim Cook, also played a crucial role in the turnaround by overhauling the way Apple built its products.

Cook, as chief operating officer under Jobs, remade Apple’s distribution pipeline to heavily rely on contract manufacturers in China, which gave it the flexibility, cost savings and scale to build such a big business.

As chief executive, Cook has also overseen most of the rise in Apple’s value. (The total value of the company’s shares was $346 billion when he took the helm in August 2011.) Cook has been a steady, if unflashy, hand as chief executive, building the iPhone into a massive business, including sales of accessories and services off it.

Now, with Apple reaching the $1 trillion milestone and the iPhone turning 11-years-old, pressure is likely to increase for the company to develop a hit new product. There have been other popular devices, like the iPad, the Apple Watch and routinely updated versions of Apple’s personal computers. But none have come close to the impact of the iPhone.

The company also has been linked to self-driving cars and augmented reality glasses, but Apple would face major technical and even social hurdles with either product.

There are other challenges. Apple depends on China for a significant amount of its sales, as well as its manufacturing. It could be caught in the middle of the trade war brewing between China and the United States.

“It’s been one of the most miraculous corporate turnarounds in business history,” said Tim Bajarin, a technology analyst and consultant who has tracked the company for nearly 40 years. “The question going forward is: Can Apple continue to innovate?”