On market day in the small Canadian town of Waterloo, Ontario, the snow covers the car parks, and horse-drawn buggies pull up alongside the pickups. Founded two centuries ago on the prairie between the Great Lakes, Waterloo is home to the global smartphone maker BlackBerry, 500 tech companies and an institute of quantum computing, but it was first settled by German Mennonites, a religious sect who reject the inventions of the machine age.

Working the land, raising barns and crafting hardwood kitchens for the many local technology millionaires, the Mennonites and their town have thrived on BlackBerry's success. But the community's future prosperity hinges on the efforts of a more recent German immigrant, BlackBerry chief executive Thorsten Heins. Appointed 13 months ago, his mission is to arrest the decline of a company whose value has crashed from a peak of $80bn (£51bn) in 2008 to $7.5bn this year.

"A year ago I felt the universe was in disarray," says Heins. "Now all the stars have really lined up." Sporting a blue shirt embossed with the company logo, his phone in a holster hung from his belt, Heins is hosting a tour of BlackBerry's sprawling 22-building headquarters.

It is two weeks after the splashy New York event, attended by BlackBerry's new creative director, the musician Alicia Keys, and beamed to press conferences in seven cities, at which Heins unveiled his company's first true internet phone, the Z10, and the BB10 operating system on which it runs.

Back home, the streets are lined with messages of support. "Proud to be powered by BlackBerry" reads the sign outside the VW car dealership. There are discounts at burger joints for customers with the right phone, and the baristas in Starbucks wear BlackBerry T-shirts. With 7,000 of its employees in Waterloo alone, every finger is crossed for the company.

BB10 took two years and 15 acquisitions to build, at a time when the firm then known as Research in Motion (RIM) was suffering the greatest upheaval in its history. In January last year, it was in a tailspin: Apple and Google had stolen its crown, with phones that were almost as powerful as laptops. RIM had played no part in the latest wave of the personal computing revolution, spending the years since the iPhone's 2007 arrival pushing email phones in emerging markets rather than improving technology, and its best-selling product was outdated.

An investor revolt wrested control from founder Mike Lazaridis and his co-chief executive Jim Balsillie. Heins took their place and set about slashing costs, eventually announcing 5,000 redundancies. He hired two Wall Street banks to seek out potential buyers, and announced the company's first loss in eight years. But Heins also redoubled efforts on the firm's biggest ever project – the building of BB10.

The Europeans brought in as his lieutenants are bullish, naturally. "We want to regain our position as the number one in the world," says Kristian Tear, the Swedish chief operating officer who came from Sony. "It could be the greatest comeback in tech history," claims marketing boss Frank Boulben, formerly of Orange. "The carriers [mobile networks] are behind us. They don't want a duopoly."

Between them, Google – whose Android software is used by Samsung, HTC and many others – and Apple accounted for 85% of handsets shipped last year, according to research firm Gartner. BlackBerry's share has fallen to 5%. Few software companies survive more than one change of operating system, and while BlackBerry leapt from making pagers to phones in the late 1990s, not everyone is confident of the same success this time. Balsillie, who unlike Lazaridis no longer holds a seat on the board, filed papers last week revealing that he had sold all his shares in the company.

"I took this job not just because I love restructuring," says Heins. "I did it because I loved the core of innovation that I saw at RIM." Many advised him to jump on the Android bandwagon, or follow Nokia's lead by taking financial incentives from Microsoft to use its Windows Phone system. Instead, he decided to follow the course set by Lazaridis, who in 2010 had bought a Canadian firm called QNX, intending to use its technology as the building block for a new generation of phones.

Like Linux, on which Android is built, QNX is a basic operating system on which the interfaces of different machines can run. While most such systems are monolithic – if one area malfunctions the whole system can crash – QNX is more stable because it uses independent building blocks or "kernels": if one breaks, there is no domino effect. As a result, it is used in the computers of nuclear power stations, high-speed trains, space shuttles and heart monitors. It is also in 60% of the engine electronics in today's high-end cars.

BlackBerry's ambition does not stop with smartphones. It now extends to connecting individuals to computers running the machines in their lives. These could be remote-controllable washing machines, switching themselves on when electricity is cheapest; cars that book their own service appointments; or dashboard touchpads that guide vehicles and pipe entertainment to their passengers.

That, says Heins, is why he chose the harder path of building BB10. "We will be extremely aggressive at investing into this mobile computing domain. We understood that if we want to create the future we have to do something really dramatic and that was building the new platform."

Reading on mobile? See the video interview with Thorsten Heins here

And so the company decided to draw on its own resources. The graphic designers took their inspiration from the clean lines of the Farnsworth House, a modernist gem near Chicago designed by the architect Mies van der Rohe. The typeface was created by Canadian Rod McDonald, who specialises in clear lettering for the partially sighted. And the engineers found a way to view more than one application at once – say the calendar and email – a conundrum Android and Apple have not yet solved.

The device's success, if it comes, will owe much to Alec Saunders, a former Microsoft employee and University of Waterloo graduate who led BlackBerry's battle to persuade developers to create as many apps as possible before BB10's launch. He joined in August 2011, in the middle of the period that is known internally as "The Crazy", and on the very day 2,500 staff were let go.

His first task was to dismantle some of the "completely unreasonable, almost Monty Python-esque" ways of working the company had with outside developers – such as the 144-page contracts no small business could digest. Saunders set out to be the developers' friend by being as open as possible. Thousands of free prototype phones were handed out last summer, the BB10 development timetable was made public, and 44 "BlackBerry Jam" shindigs for developers were held in 33 countries.

Local teams chasing local content were appointed in almost all of the 20 most prolific app-producing nations. Only Japan, where BlackBerry is withdrawing from the market, and South Korea, where Samsung is hard to work around, were left off the list. There were financial incentives too – $100 for the most basic apps, and a guarantee of $10,000 revenue in the first year for the most popular. When the Z10 made its worldwide debut in the UK, it came with 70,000 apps. By the time it reaches the United States in March, there will be 100,000.

"What we accomplished was monumental," says Saunders. "We persuaded developers to build apps for a platform without the prospect of being able to make any money for months, and they did it."

The company says that the Z10 performed three times better during its first week in the UK than any previous BlackBerry smartphone. That's a vague metric – and claims that UK stores ran out of stock were undermined by analysts Canaccord Genuity, which found most branches received less than 15 handsets each. We will know more on 28 March, when BlackBerry's next set of financial results are published. Ambitions about using QNX to connect to the real world do not a business plan make – BlackBerry's future rests on sales of its new phones.

Tellingly, the company's bankers, JP Morgan and RBC Capital Markets, remain on standby, ready to negotiate a sale. Chinese manufacturer Lenovo, which bought IBM's PC business in 2005, has expressed an interest.

Heins says BlackBerry's independence is in the balance. "Are we out of the woods? No I don't think so. I think we need to still continue working at it and the strategic review is still part of it. As management we always need to assess the options that we have at our fingertips."

At today's price, a takeover could put at least $13m in cash and share options in the chief executive's pocket. But BlackBerry's stock is at a 10-year low: the creation of a true smartphone and what the industry likes to call an "ecosystem" of apps should make it far more valuable to a buyer than the company Heins took control of a year ago. Should BlackBerry meet its Waterloo, it will mint a few more millionaires in the process.