The short answer is through self-reliance. On the physical level this involves his ability to survive through unimaginably trying conditions. But his self-reliance also finds expression through Pi's intellectual and imagination. By creating the story of Richard Parker, Orange Juice, et al., he finds a way to cope with the intense mental anguish and loss he has suffered. When his Japanese interlocuters meet his tale with incredulity, he indulges them with the "actual" account of his 227 days at sea. This ability to simultaneously hold both narratives in mind reflects an emotional maturity.
Pi's complex and nuanced spirituality might suggest that he also relies on a higher power for his survival, but ultimately he can fall back on his own capacity to entertain and accommodate what are conventionally viewed as conflicting world views (see the humorous row between the three clerics in the first half of the book). It is Pi's astonishing power to not only endure an unthinkable reality but out of it to alchemize an intensely compelling and salvific allegory stands as a truly thought-provoking coming-of-age narrative (a term which hardly does justice to the novel).
The final irony, Pi's safely middle-class existence from which the surreal story unfolds, may be read as an ackowledgement that the for the mature individual, the apparently simple life is far more satisfying than the wild maelstrom out of which it is born. Pi appears to have reached that place at the novel's end.