Earlier this year, Twitter said that it had reached a deal with Google that would see the search giant get access to the Twitter “firehose” of half a billion tweets or so a day. The first tangible sign of this new relationship appeared on Tuesday, when Google announced that tweets would soon begin showing up in mobile searches—the first time that comprehensive results from Twitter have been available in Google since 2011 (tweets in desktop results are coming soon, the search company says).

Google has shown selected tweets and Twitter accounts in its search results before this week, but it has only been able to do so by “scraping” the Twitter website, so it hasn’t been able to integrate specific relevant tweets in the way it can now that it has an actual deal.

So why have Twitter and Google suddenly decided to play ball on search results again? The short answer is that both companies have realized that they have a lot more to gain from being friends than they do from remaining estranged. In fact, the only difficult part of the arrangement is trying to determine which company is going to benefit the most.

And why did the relationship fall apart in the first place? Versions of the story differ depending on whom you talk to, but it sounds as though Google thought Twitter was getting a little too big for its britches when it asked the search company to pay for access to its firehose in 2011. And the search giant may also have thought that the social network looked a bit too much like a potential competitor, especially if it focused on search.

Twitter, meanwhile, reportedly felt that Google search results weren’t going to be a meaningful source of user growth or revenue—and it was also concerned that Google might use some of the firehose data to help its own Google+ social platform.

Whatever the actual cause of the original breakup, Google went on to try and build its own social network with Google+, a service that has suffered ever since from the perception that hardly anyone uses it—even though it became a kind of “identity layer” for all of Google’s products. And Twitter went on to pursue other avenues for growth, and to launch its much-awaited IPO in 2014.

Fast forward to today: The chief architect of Google+, Vic Gundotra, has left and the service is being split into several component parts, including the “Stream,” as well as Photos and Messaging. Despite (or possibly because of) its ambitions, the Google platform never actually achieved anything like the kind of ubiquity that Twitter has, and as a result Google has become increasingly disconnected from the “real time” social web that Twitter and Facebook represent.

Doing a search-integration deal with Twitter helps fill that gap for the search behemoth. And according to some reports, Google is not paying Twitter anything for tweets that are clicked on in search results (although it may be paying a standard licensing fee, the way other subscribers to the firehose do).

Twitter results in Google search
Twitter/Google

You can also get a sense of how much this deal means to Google by the amount of real estate it is devoting to Twitter results in search. Even on a mobile device, where screen real estate is at a premium, Google gives tweets a fairly large chunk of the available display, and in many cases the tweets are right at the top—the place often reserved for the results from Google’s own properties.

Twitter, meanwhile, is a very different company from the one that cancelled the Google deal in 2011. For one thing, while it is generating substantial amounts of revenue from its promoted tweets and other advertising features, investors have perceived its overall user growth and engagement metrics as rather underwhelming. In other words, generating some kind of boost in the latter probably means a lot more to the company over the long term than charging Google an arm-and-a-leg for access.

Twitter has also spent much of the past year or so trying to convince Wall Street analysts that engagement by logged-out Twitter users—and even casual non-Twitter users who come across the network’s content—is almost as valuable as activity by logged-in users. The Google deal feels like the company’s attempt to put a little more wood behind that particular arrow. And the result is that for now, at least, Twitter and Google see each other as friends because their goals are aligned.