Use Guard against the blades that Ansem's guardian shadow--which can block Ansem from your attacks--shoots out.
The guardian will posses Sora and change his attack command to Freeze. If you attack during this time, the guardian will come out and grab him for a while. If you don't do anything, it will occasionally come out and damage Sora, which is a good time to go after Ansem.
Ansem can charge at you, now, which is a bit hard to dodge and he also does a lightening attack that doesn't do much damage. The easiest thing to do is to keep Aeroga on during the entire battle, which can block Ansem's charge attack and slowly drain Ansem's life.
When he says 'My strength returns...' the guardian will start shooting up from the ground and try to hit you, easily avoided by using Dodge Roll. When the guardian possesses you, use special abilities.
Ansem first. If you keep attacking, you should do well, although he uses his staff to bat you away and shoots energy beams at you.
Once he knocks you into a portal, attak the Shadows that appear and look for a giant nasty thing, which, if you attack it, will cause a black portal to appear back in front of Ansem. Attack the blubber things and fly over and into it. Destroy the Darkballs and nasty thing to release Goofy.
Take care of the blubbery things so as not to be distracted and ignore the energy/lightening damage to attack the face, healing when it is required. After defeating the face, you get 3000 EXP. When it opens, enter the new portal and destroy the Invisibles and final nasty thing to free Donald.
Now the shield at the center of the ship will go away. Focus on the blubber with the jack-o-lantern face until it explodes, but don't ignore the other blubbery things.
Now, Ansem is not protected by the Heartless shield, so go and pick a fight with him as the last portion of the battle. He has a new vortex attack and uses more lasers. When the vortex opens up, fly away quickly or face the loss of a good deal of your HP.