Ionic is based on cordova or Phonegap?

I am very new to ionic and cordova/Phonegap.
I am trying to understand ionic.
I have just installed ionic and created a sample application and also able to run it.

At the beginning, I have started with Phonegap installation and building demo using Phonegap.

At the time of installation of of ionic I have also installed cordova.
But I am confused if ionic is using Phonegap or cordova ?

Also if it is then what all things are used by ionic from either from Phonegap or cordova?