At the end of Thor: Ragnarok, Thor's ship encountered Thano's vessel. A battle ensue. Hulk is hurled away through the cosmos and crashes on Strange's sanctum sanctorum. Banner warns Strange about Thanos' coming and his quest for the infinity stones. Stark, Strange, Spidey go through the NY portal to face Thanos in an alien world, where Thanos is torturing the Collector for the Reality Stone handed to him by the asgardians back on Thor: Dark World.
Back on Earth, Proxima Midnight and Ebony Maw from Thanos' crew ambush Vision to steal the Mind Stone. Cap, Bucky, Widow and Hawkeye show up to the rescue. Hawkeye dies while the rest of the heroes take Vision to Wakanda.
Then comes the Wakanda invasion, because now there's two infinity stones there: the mind stone on Vision's forehead and the soul stone.
In the end, Thanos gathers all the stones, snaps his fingers, half of humanity disappears, including several of our heroes and the movie ends.