On the feed I was watching it showed that only attacker's hand was passed the line. Hands and feet are exempted for the offside rule.
Messi was offside on the initial pass to Martinez (which you can't really see in the clip because of the close-up shot) but was back onside by the time Martinez passed it back to Messi (which you do see). So it's a good goal.
They did replay the entire sequence on the US Fox broadcast without the close-up.