The following is my interpretation of the end of the series. It does not necessarily reflect the original author's opinion.
Unmarked Spoilers Below
The point of Ed's sacrifice at the end of the series is that he finally understood the truth about alchemy, and, more specifically, the Law of Equivalent Exchange.
In the intro, Alphonse says:
To obtain, something of equal value must be lost. That is alchemy's first law of Equivalent Exchange. In those days, we really believed that to be the world's one, and only truth.
At the start of the series, Ed and Al believe wholeheartedly that almost everything can be solved with alchemy. That's why they attempted human transmutation to begin with - they see everything as an alchemical equation. They felt that there must be some way to bring back their mother using alchemy, and that there must be some way to restore their original bodies as well.
However, as the series progresses, the brothers begin to discover holes in this seemingly ironclad (fullmetal?) law of alchemy. They discover that Izumi Curtis had also attempted human transmutation, trying and failing to revive her infant child. Following this, when Edward spends some time in Resembool after visiting the ruins of Xerxes, Hohenheim suggests that the creature they transmuted back at the beginning of the series was not even their mother. Upon examining the remains, he and Pinako confirm that this is indeed the case. Knowing this, Edward comes to the conclusion that bringing someone back from the dead is impossible, which he tells Izumi in Episode 20.
This revalation is significant. If there are some things that are impossible with alchemy, like bringing someone back from death, it implies that there may be some things that do not have a set alchemical value. This throws a wrench into the law of Equivalent Exchange, since if not everything can be quantified by alchemy, Equivalent Exchange cannot be the only truth of the world.
What this other truth is, though, eludes everyone up until the climax of the series, when Edward performs his final transmutation. He realizes how he can get his brother back and keep his body. As he does this, Hohenheim seems to figure it out, too.
At this point, Edward faces Truth, and offers him his own personal gate of truth in exchange for Alphonse's body. They exchange the following dialogue (English sub of Japanese dub):
Truth: You would lower yourself to become just a normal person, unable to use alchemy?
Edward: "Lower myself," nothing. I've been just a person from the start. An insignificant human who couldn't save a little girl who had been made into a Chimera.
Truth: You're sure you'll be okay without it?
Edward (thinking of his friends and family): Even without alchemy, I still have them.
Truth: That is the right answer, alchemist. You have beaten me. Take it with you. All of it! The back door is over there, Edward Elric.
Edward has realized something critical, something that circumvents even Equivalent Exchange. What gives him value is not his ability to do alchemy, but his loved ones. In Ed's eyes, he does not exchange anything of value, yet gains "everything" (his brother, his friends, and his family). He has not been lowered or decreased at all by losing his gate ("I've just been a person from the start"), but has instead increased.
Alphonse expands on this principle when he meets with the Hughes family in the epilogue:
Alphonse: We were afforded a lot of happiness, a lot of happiness, in a lot of places by a lot of people...including Mr. Hughes. And so, now, we feel it's out turn to return the favor.
Gracia: Is that equivalent exchange, like the alchemists say?
Alphonse: No, by taking ten, and giving ten, it all ends up the same. So we take ten, put something of ourselves on top of it, and return 11. It's not much, but it's a new principle we've hit upon. Now we have to go and prove it.
This "new principle" as Alphonse puts it, is that hidden truth beyond Equivalent Exchange. It's what Edward did to get Al's body back - he took what was there (his own body), added some of himself (his gate) and was able to come out with more than what he came in with (his body and his brother).
Winry reinforces this idea again right at the end of the last episode:
Edward: Equivalent exchange! I'll give you half of my life, if you give me half of yours!
Winry: Why do alchemists have to be like this? The principle of equivalent exchange is all nonsense, isn't it?
Edward: What did you say?
Winry: It really is nonsense. Never mind half, I'll give you all of it.
Edward (after some banter): You really are amazing! You turn equivalent exchange on its ear so easily!
Winry, by giving Ed "her whole life" (or at least 85 percent of it) is once again not decreasing or losing anything, but instead gaining something, just as Ed is gaining something by giving her his whole life.
Ed drives this point home with his final line:
Edward: There's no point to lessons that don't bring with them pain. People can't gain anything without sacrificing something, after all. But once you've successfully endured that pain, you gain a heart that is stout enough not to be overcome by anything. Yeah, a heart made fullmetal.
When you go through a painful lesson, you pay the price in pain, and in turn, gain a lesson learned, but you also gain something extra - a heart made fullmetal, able to withstand anything.
So, to answer your question, he beats Truth by realizing that there are things alchemy cannot quantify, things with infinite value, and by choosing them over alchemy, he has effectively gained everything and lost nothing.