I don't believe that it was the 'piece of soul' within Harry which enabled him to resist the Imperius curse.
- From what we read in the books, Harry has a very strong will. A will to survive, a will to do the right thing and a will to be strong1. Having a strong will is how you counter the Imperius Curse.
- There is no evidence that Voldemort was able to resist the Imperius curse, so why should the piece of his soul within Harry do that?
Lets break it down a bit:
And then he heard Mad-Eye Moody's voice, echoing in some distant chamber of his empty brain: Jump onto the desk. . . jump onto the desk. . .
It seems as though what the Imperius Curse does is it causes the victim's mind to be overcome by the caster's will. Sort of a "shove along, i'm in control here" notion.
Why, though? Another voice had awoken in the back of his brain.
Stupid thing to do, really, said the voice.
Harry's brain hears Moody's voice thinking that the voice belongs to the brain. But when Harry's voice comes in, it seems like it is out-of-place; but that is only because Moody has taken over.
Jump onto the desk....
No, I don't think I will, thanks, said the other voice, a little more firmly. . . no, I don't really want to.
Harry's "voice" or will starts to take over and become stronger, eventually over-powering Moody's.
Note that the same thing happens the other time Harry is put under the Imperius Curse:
“I asked you whether you want me to do that again,” said Voldemort
softly. “Answer me! Imperio!”
And Harry felt, for the third time in his life, the sensation that
his mind had been wiped of all thought. . . . Ah, it was bliss, not to
think, it was as though he were floating, dreaming . . . just answer
no . . . say no . . . just answer no. . . .
I will not, said a stronger voice, in the back of his head, I won’t
answer. . . .
Just answer no. . . .
I won’t do it, I won’t say it. . . .
Just answer no. . .
And these words burst from Harry’s mouth; they echoed
through the graveyard, and the dream state was lifted as suddenly as
though cold water had been thrown over him — back rushed the
aches that the Cruciatus Curse had left all over his body — back
rushed the realization of where he was, and what he was facing. . . .
-Harry Potter and the Goblet of Fire, Chapter Thirty-Four (Priori Incantatum).
Pretty inconclusive; but this is all of the evidence I could dig up.
One thing's for certain: Harry was extremely strong willed, and we know that that seems to be the one thing that someone needs to reject the Imperius Curse.