The Battle of Titan was an attempt by a combination of Avengers, Guardians of the Galaxy and Doctor Strange, to ambush Thanos and defeat him.

Background

On his quest to obtain the six Infinity Stones, Thanos tasked his four Children to obtain the Mind and Time Stones on Earth, before bringing them to him on his homeworld, Titan. The Children split up to complete this task, with Ebony Maw and Cull Obsidian making for the Sanctum Sanctorum in New York to retrieve the Time Stone from its keeper, Doctor Strange.

During the attack on the Sanctum, Maw managed to immobilise and capture Strange and the Stone which was protected by a magical seal conjured by Strange. Taking them back to his Q-Ship to bring to Thanos, Maw set the Ship on an automated course for Titan. However, the Ship was unknowingly boarded by Iron Man, Spider-Man, and the Cloak of Levitation, who, in a brief conflict, managed to release Strange and kill Maw, commandeering the Ship.

However, in lieu of returning the Ship to Earth, Iron Man decided to continue on their course to Titan - in a gambit to ambush Thanos directly in his own territory, where he would not be expecting an attack, and to protect Earth from further collateral damage.

Elsewhere, the Guardians of the Galaxy were on a separate quest to stop Thanos. Splitting up, Star-Lord, Mantis, Drax the Destroyer, and Thanos' adoptive daughter, Gamora attempted to ambush Thanos on Knowhere to prevent him taking the Reality Stone. However, the Guardians were themselves outwitted, resulting in the capture of Gamora, who held crucial information that Thanos required - the location of the Soul Stone.

To prevent Thanos from torturing her captive sister Nebula, Gamora revealed the location of the Soul Stone to be on Vormir. However, to fulfil the price required to obtain the Stone, Thanos reluctantly sacrificed Gamora to the Stone.

Unaware of Gamora's death, the remaining Guardians, acting on a tip from the escaped Nebula, landed on Titan with the aim to ambush Thanos there. Shortly after, the Q-Ship carrying Strange, Iron Man and Spider-Man crash-landed on the barren planet. The Guardians raided the Ship and attacked the Avengers, each believing the other to be working for Thanos.

However, after a tense standoff, both parties realised they shared the same goal, before deciding to work together to ambush Thanos, who they expected to be arriving soon.

Awaiting Thanos' arrival, Iron Man, Spider-Man and the Guardians attempted to formulate a plan of attack, Strange activated the Time Stone to view all possible outcomes and futures of the coming battle. Having seen exactly 14,000,605 possible timelines, Strange gravely informed the others that only one timeline ended in Thanos' defeat.