Mortuary temples (or funerary temples) were temples that were erected adjacent to, or in the vicinity of, royal tombs in Ancient Egypt. The temples were designed to commemorate the reign of the Pharaoh under whom they were constructed, as well as for use by the king's cult after death. Some refer to these temples as a cenotaph. 
Mortuary temples were built around pyramids in the Old Kingdom and Middle Kingdom. However, once the New Kingdom pharaohs began constructing tombs in the Valley of the Kings, they built their mortuary temples separately. These New Kingdom temples were called "mansions of millions of years" by the Egyptians.
The mortuary temples were also used as a resting place for the boat of Amun at the time of the Beautiful Festival of the Valley, during which the cult statue of the deity visited the west bank of Thebes.
The first mortuary temple was built for Amenhotep I of the 18th Dynasty during the New Kingdom. Several other rulers of this dynasty built temples for the same purpose, the best known being those at Deir el-Bahari, where Hatshepsut built beside the funerary temple of Mentuhotep II, and that of Amenhotep III, of which the only major extant remains are the Colossi of Memnon.
Later rulers of the 18th Dynasty either failed to build here at all or, in the case of Tutankhamun, Ay, and Horemheb, their construction was not completed. The 19th Dynasty ruler Seti I constructed his mortuary temple at what is now known as Gurna. Part of his "Glorious temple of Seti Merenptah in the field of Amun which resides at the West of Thebes" was dedicated to his father Ramesses I, whose short reign prevented him from building his own, and was completed by his son Ramesses II. The mortuary temple of Hatshesput was build around 1490 B.C. It is the only royal funerary temple from the time period to remain in good condition.
Ramesses II constructed his own temple, referred to as the Ramesseum (a name given to it by Champollion in 1829): "Temple of a million years of Usermaatre Setepenre which is linked with Thebes-the-Quoted in the Field of Amun, in the West".
Much later, during the 20th Dynasty, Ramesses III constructed his own temple at Medinet Habu.