Gintama is the comedic samurai vs aliens themed manga series set in the Edo era that's written and illustrated by Hideaki Sorachi which has also been adapted into a TV anime produced by Sunrise.
During the late Edo era, humanity is attacked by a strange alien race known as the Amanto. The samurai class rally in humanity’s defense, but once the Shogun sees the aliens’ immense power he surrenders allowing the aliens into Japan and banning the carrying of swords so that the samurai can no longer defend themselves.
The series follows the adventures of one eccentric former samurai - Gintoki Sakata. Gintoki acquires an apprentice, Shinpachi Shimura, after helping him save his sister from a gang of aliens. Later a third member joins the crew in the form of a teenage alien girl, Kagura, after Gintoki and Shinpachi save her from some bloodthirsty yakuza.
The trio become known as the Yorozuya and frequently come into contact with the Shinsengumi police force and also some of Gintoki’s former samurai comrades including Kotaro Katsura and Shinsuke Takasugi, who is now a dangerous enemy dead set on destroying the bakufu!