Was it a gradual thing, or was there a decisive moment in history when it happened?
Also, when exactly did the US and UK become friends rather than rivals?
This is a very large and complex set of questions! I don't dare to try to answer them all with complete satisfaction, as each aspect could be a book in its own right. I will, however, offer what I can as a historian of modern empire.
When did the US supplant the UK as a superpower?
Was it a gradual thing, or was there a decisive moment in history when it happened?
First, the term 'superpower' is generally reserved for the US and USSR with specific reference to the Cold War ideological divide. Ignoring that term, the final 'supplanting' of the UK by the US comes in waves, with a staggered number of changes occurring during the 19th and 20th centuries. There are rarely 'decisive moments' when it comes to geopolitical variables like 'soft power' or 'hard power,' but I'll give some examples that could be used:
1.) Domestic Power: The US surpassed UK in both industrial and financial power by the late-19th century - the decisive 'moment' (in which British financiers/industrialists began to truly realize this) was during World War I, at which point New York City began to rival London as a source of credit, loans, insurance, and financial soft power.^1 This is critical to understanding the transfer of power, as much of Britain's economic strength (and thus its global power projection) relied on being the de facto money market and insurance hub for the western world.^2 By the end of the war, for example, British investments in the Americas were virtually non-existent (much of this money had been pulled back into Britain for the sake of the war effort), leaving the entire western hemisphere in the grip of the United States (financially-speaking). It only got worse from this point forward for Britain.
2a.) External Power: The Monroe Doctrine of 1823 was the US's first major attempt at soft power influence in the Americas. It was not received well by Britain, but British imperial eyes were elsewhere at the time (edit: for clarity, see my post here. The lack of overt challenge to the doctrine boosted its credibility, and it became the foundation for the US's shift away from isolationism by the end of the 19th century. For the US, the Spanish-American War of 1898 marked the culmination of major shifts in foreign policy, especially because of its peace treaty. US interests in the Pacific were substantially increased, and US foreign power was generally viewed as more potent force than before.^3 In fact, this war directly inspired Kipling's (in)famous poem, "The White Man's Burden: The United States and the Philippine Islands", which - though often taken out of context now - was issued as a call-to-arms for the US to join Europe in the colonization and 'uplifting' of the non-western world. This brings up an important point: the Monroe Doctrine, though a unilateral declaration, had bilateral repercussions, as it was essentially a soft promise to the US to solely meddle in the affairs of the Americas. It was less of a 'line in the sand' for Europe, therefore, and more of a non-aggression offer: you (Europe) stay out of the Americas, and we'll stay out of your affairs. After the events of 1898, American power was viewed in Britain as a force too large to be contained within the Americas - as such, this force must be groomed to match the goals and ambitions of the other imperial powers of Europe. A powerful example of this comes from Woodrow Wilson, who once said that "I will teach the South American republics to elect good men or else." This statement meshes with the 'civilizing mission' employed by Britain and France in Africa, and - as such - highlights that their relative imperial endeavors had common and compatible goals.
2b.) If the US was just emerging as an overt imperial power in 1898, at what point did it 'surpass' Britain? Again, this is an abstract concept, as you can't quantify 'imperial power' so easily. I will, however, point to the Suez Crisis of 1956 as a fairly pivotal moment in which Britain was forced to acknowledge and acquiesce to the demands of the United States. I'll leave the details of the moment out (for the sake of brevity), but suffice to say that Britain's relinquishment of the canal to Egypt in 1956 was a direct consequence of US pressure in the UN. British power in 1956 had been in decline since World War I, to be sure:
Its naval fleet, once the largest in the world by a factor of 3:1, was now eclipsed by the US's.^4
The loss of India in 1947, and most of British Asia in the decade that followed, left the Pacific uncontested vis-a-vis the US, and dealt a mortal blow to Britain's land-based military power.^5
Challenges in Palestine and the Middle East opened a vacuum of power for the USSR and US in the region in the 1950s.^6
Britain's declining military power globally pushed territories and commonwealth states like Canada and Australia, towards the US as a new military ally.^7
In spite of these clear shifts in power, the tacit acceptance of British global power was not overtly questioned on the global stage until the Suez Crisis. This event humiliated Britain, and elevated the US's global power as a result.
Also, when exactly did the US and UK become friends rather than rivals?
3.) Friendship: Long-story short (this post is getting long), let's not forget that Britain and the US share a common cultural bond. War of 1812 and some tensions during/after the Civil War aside, Britain and the US had compatible, parallel goals in the world. They pursued these paths differently during the 19th century (the US carved out a continent-spanning empire in the Americas, Britain carved out an empire in Asia, Africa, and the Middle East), but success in one hemisphere did not diminish success in another. In fact, American prosperity, even after America eclipsed Britain industrially and financially, directly benefited Britain from the end of the War of Independence to the present, as Britain and the US were (and are) vital trade partners. This relationship became a military alliance during WWI and WWII, and then shifted into a soft-power alliance (with some aberrations, as in 1956), during the Cold War. In all, however, I would not solely use the term 'rivalry' to describe the US/UK relationship at any single point in their shared history after the conflict of 1812.^8
I'm happy to take any follow up questions, as I did gloss over some things in the interest of time.
Cheers,
Gazebo
^1 See Lens, Forging of the American Empire, p 242 for more on this.
^2 I can't really offer a specific page, but Cain and Hopkins's seminal work British Imperialism 1688-2000 is a must-read on this topic.
^3 See Ninkovic's The United States and Imperialism
^4 See BJC McKercher's Transition of Power: Britain's Loss of Global Pre-Eminence to the United States
^5 See WR Louis's amazing Imperialism at Bay for more on this. Really, Louis and McKercher's books can answer pretty much any follow up question you may have.
^6 See Louis's other great Work Ends of British Imperialism.
^7 See J.L. Granastein's How Britain's Weakness Forced Canada into the Arms of the United States
^8 CJ Bartlett has an interesting read on the 'special relationship' : "The Special Relationship:" A Political History of Anglo-American Relations since 1945.