SAN JOSE -- Google two years ago agreed to cover some of Samsung's potential legal costs as protection against Apple's latest multibillion-dollar patent lawsuit, a rare glimpse into how closely the two companies aligned themselves in the smartphone wars, a federal court jury learned Tuesday.

Apple disclosed emails and letters showing that Google executives agreed to pay some of Samsung's legal costs if it loses its patent fight against Apple. Apple unveiled the evidence to show that Samsung and Google are intertwined. The tactic was meant to undermine Samsung's argument that it has nothing to do with whether Google-based technology integral to its smartphones and tablets violates Apple's patent rights.

Central to Samsung's defense is its argument that Apple should have targeted Google because the patents at issue in the trial are based on Google's technology and its Android operating system, which has run Samsung smartphones and tablets.

But Apple put the previously secret 2012 Google agreements in front of the jury to bolster its position that Google's role is irrelevant because Samsung controls the technology it includes and sells in its own smartphones and tablets.

The evidence surfaced as Apple and Samsung reach the final stage of their epic federal court showdown. The Google indemnity agreements cover two of the five patents Apple has asserted in the trial.

Google representatives could not be reached for comment.

With a few pieces of testimony left to finish Friday, lawyers for the feuding smartphone powers will turn to finalizing a thick packet of instructions for the eight-member jury and head to closing arguments Monday.

On Thursday, Samsung wrapped up its case against Apple, which is accused of violating two of the South Korean tech giant's patents, including one video patent alleged to be involved in the iPhone's FaceTime feature. A Samsung expert told the jury that Apple should pay about $6 million for infringing those patents.

Apple argues that its technology does not infringe any Samsung patents.

Samsung's case against Apple, however, is a sideshow to the four-week trial's main event. Apple has urged the jury to find that Samsung smartphones and tablets violate five software patents in iPhones and iPads, and has asked the jury to award about $2.2 billion in damages.

Samsung disputes infringing those patents, arguing they were for the most part developed by Google as part of its Android operating system. In addition, a Samsung expert has valued the Apple patents at about $38 million, a fraction of the royalties sought by the iPhone maker.

The jury could begin deliberating as soon as Monday afternoon.

Howard Mintz covers legal affairs. Contact him at 408-286-0236 or follow him at Twitter.com/hmintz.