Aladdin arrives and defeats Jafar .
When Jafar is about to turn around - which would mean he would spot Aladdin , she kisses Jafar , but then Jafar sees Aladdin anyway and attacks him . Aladdin ultimately outwits Jafar and has him imprisoned in a lamp of his own ( as Aladdin tricks Jafar into wishing to be an all-powerful Genie ) .