In the summer of 1995, a second-year grad student called Sergey Brin was giving a tour of Stanford University to prospective students. Larry Page, an engineering graduate from the University of Michigan, was one of those being shown around the Palo Alto, California campus.

“I thought he was pretty obnoxious,” Larry Page said of the encounter. “He had really strong opinions about things, and I guess I did, too.”

“We both found each other obnoxious,” said Sergey Brin. “But we say it a little bit jokingly. Obviously we spent a lot of time talking to each other, so there was something there

The technology of the web at the time meant that you could tell where a webpage links to just by reading its code; but the only way to find out where it is linked from is to see it linked to from another page. In other words, to get an exhaustive list of every page that links to, say, stanford.edu, you need to check every other website on the internet.

Page’s “Backrub” project aimed to qualify these backlinks, a complex task that not only demanded huge computing resources, but also required extremely complex mathematics, which is where the maths prodigy Brin came in.

Facebook Twitter Pinterest A team-photo of members of the growing Google team in Palo Alto, California, before the move to Mountain View. Photograph: Google Llc Handout/EPA

In 1996 they began experimenting with the Stanford homepage and soon came up with the PageRank algorithm – a ranking system which would prove to be Page and Brin’s breakthrough idea.

The algorithm was devised to give more weight to links that came from more authoritative pages – the more backlinks a site had, the more likely it was to be a good source, similar to an academic paper. That allowed Page and Brin to rank search results not only by keyword frequency but by authority. And because the system analysed links, the more the web grew the better Backrub got.

In August 1996, Backrub became Google, a play on the term googol, meaning the large number 10 to the power of 100. The first version appeared on the Stanford site, run from cobbled-together bits of computers scavenged by Page and Brin. The system demanded so much bandwidth it would regularly take down the whole of Stanford’s internet connection, but it succeeded in letting users search all 24m pages it had stored in its database.

On 15 September 1997 Google.com was registered and by August 1998 the first Google Doodle appeared – a Burning Man figure that was intended to let everyone know that both Page and Brin were at the festival in the Nevada desert.

Google also got its first funding in the form of a cheque for $100,000 written by Andy Bechtolsheim, co-founder of Sun Microsystems, in August 1998 to “Google Inc”. The trouble was that Google Inc didn’t exist yet, so after a rush to get the paperwork lined up Google was incorporated on 4 September 1998 so the pair could bank the cheque. Later that month the duo moved out of their dorm rooms and into the garage of friend Susan Wojcicki (now CEO of YouTube) in Menlo Park, California, complete with ping-pong table and bright blue carpet, receiving further investment from Amazon founder Jeff Bezos, among others.

Early in 1999, Page and Brin attempted to sell Google to Excite, then number two search engine behind Yahoo, for $1m, but even after the pair had been talked down to $750,000 by Excite venture capitalist Vinod Khosla, Excite CEO George Bell rejected them - although why he did remained a matter of debate for years. Page and Brin had also reportedly attempted to sell their technology to then search engine Altavista and Yahoo in 1998 to no avail.

With no buyer in sight, Google started hiring engineers and moved out of the garage to an office in Palo Alto in March 1999. In 2001, seeking so-called “adult supervision” for the company, Eric Schmidt was hired first as chairman and then CEO, taking over from Page. Schmidt was hired over some 50 other candidates because he had been to Burning Man, but he was tasked with the traditional corporate side of the business, leaving Page and Brin to continue to develop Google’s products and technologies respectively.

By the end of its first decade, Google had effectively won the search-engine wars. PageRank had provided it its first major leg-up, letting it offer a better search experience than any of its competitors. To this day, the Google homepage remains clean and sparse, offering nothing more than a logo, search field, and two buttons.

But the pivot that saw Google go from dominating a service to dominating an industry occurred when the company realised it needed to go outside its areas of expertise, and began an acquisition spree that would seed its evolution to the global behemoth it is today.

Arguably, its most important purchase was YouTube, bought for $1.65bn in stock, then the largest purchase the company had made. Unlike many of Google’s previous acquisitions, where the company bought in technology it couldn’t make itself and threw its corporate weight behind making the resulting product success, YouTube was already a phenomenon, and Google had spent its own resources building a direct competitor, Google Video.

But YouTube’s lead was already becoming difficult to compete with. Google was able to build a Flash-based video player in-house, but without the huge array of videos that were already on YouTube, it had no viewers, and with no viewers, there was no reason for anyone else to upload video – a vicious cycle. So Google made a still rare move, and bought, not technology, but users.

The purchase price was eye-watering for the time, with the New York Times reporting that it sounded “like a tale from the dotcom bubble”, but the story also contained a more telling quote from Steve Ballmer – then Microsoft’s chief executive. “If you believe it’s the future of television, it’s clearly worth $1.6bn,” Ballmer said.

The bet paid off. YouTube’s ad revenue alone was projected to be $4bn this year.

What will be the next YouTube in Google’s portfolio? The company seems to think it will come from the world of AI. In 2014, Google bought AI company DeepMind for a reported $500m, augmenting its own AI efforts which had been bundled together into the Google Brain unit. DeepMind has continued to operate largely independently as a research-focused institute, most famous for its AlphaGo AI, which became the first machine to beat a professional player of the ancient Asian boardgame Go in 2016.

Facebook Twitter Pinterest Page and Brin in 2004. Photograph: Ben Margot/AP

Regulation, censorship and competition all threaten Google’s crown. The company’s first brush with governmental pressure came when the Chinese government’s internet filters started intermittently blocking Google.com in the year 2000. In 2006 the company decided to officially launch Google.cn, a decision which drew widespread criticism, since with a Chinese website came Chinese web censorship – something that Brin, who was born in the Soviet Union, was vocally uneasy with acceding to. Nonetheless, the censorship lasted until 2010, when Gmail became the target of a cyber-attack that the firm believed was attempting to gather information on Chinese human rights activists.

It was recently revealed that the company is running a project, Dragonfly, aimed at producing a newly censored version of its search and news products, ready for a re-entry to China.

But it’s not just repressive regimes that have forced Google to toe the line. In Europe and the US, the company has also had to give ground to legislatures, regulators and the judiciary.

One of the company’s first areas of conflict was over copyright. Less than three months after Google bought YouTube, it was hit with a lawsuit from US media conglomerate Viacom for copyright infringement, a battle that would rage for seven years. Viacom had a strong case, noting that more than 150,000 clips of its copyrighted shows were available on the video-sharing site.

But Viacom’s argument was slightly undercut by the revelation that it had uploaded much of the material itself. “For years, Viacom continuously and secretly uploaded its content to YouTube, even while publicly complaining about its presence there,” YouTube’s chief counsel wrote in 2010. The case was finally settled in March 2014. No money changed hands.

Another copyright conflict had potentially larger ramifications. Agence France-Press sued Google in March 2005 for $17.5m for allegedly using its photos and stories on Google News without permission, leading to an arrangement to host various news agency content starting in 2007. That suit was followed by one from the Belgian newspaper group Copiepresse, and complaints from the French and German journalism bodies as well.

The rows over Google News have continued, in some form or another, for the past decade, and Google has been forced into many concessions: paying licensing fees in some countries, settling out of court in others, and creating charitable funds to support journalism elsewhere.

Facebook Twitter Pinterest A computer display shows knockoff websites of both Google and YouTube in China, 2010. Photograph: Ng Han Guan/AP

But while it lost some battles, it won the war, for the simple fact that Google News became too big for publishers to ignore. When, in Germany, Google offered the ability for publishers to remove their content from the search engine, Axel Springer, one of the country’s largest publishing companies, took the chance. It told Google the company would have to pay or cease to run images and snippets of text from Axel publications. Google chose the latter option, and, Axel said, traffic plunged. It bowed out of the fight after just two weeks.

The size of Google is undoubtedly a strength in fights like that, but it opens another avenue of attack for regulators: it is, in some areas, a monopoly. That means it has to be very careful about how it wields its power, or it will fall prey to competition regulators. In Europe, that process has already begun, with the commission finding that Google had abused its monopolies in search engines and mobile phone app stores. The company has been fined €6.7bn for those two breaches.

Regulations aren’t the only threat on the horizon for Google, though. Amazon is going after Google’s crown jewels: search advertising. Almost 90% of Google’s revenue in the last three months came from advertising, and Amazon could seriously threaten its dominance of online retail if this continues.

Facebook has a more fundamental line of attack: it wants to kill the web. A Facebook future is one in which a significant proportion of humanity’s data sits, not on the open web, but on the closed social network. That would cut Google off from the information it can search, index and make available, forcing it into ever more extractive relationships with its own users as data sources instead.

Of course, the threats could come from a company which doesn’t even exist yet. Maybe one that’s being founded today, and in 20 years time will be ready to take on Google, just like Google has taken on the legacy stars of its own industry.