On the technical side, Aikido is rooted in several styles of jujitsu (from which modern judo is also derived), in particular daitoryu-(aiki)jujitsu, as well as sword and spear fighting arts. Oversimplifying somewhat, we may say that Aikido takes the joint locks and throws from jujitsu and combines them with the body movements of sword and spear fighting. However, we must also realize that many Aikido techniques are the result of Master Ueshiba's own innovation.
On the religious side, Ueshiba was a devotee of one of Japan's so-called 'new religions,' Omotokyo. Omotokyo was (and is) part neo-shintoism, and part socio-political idealism. One goal of omotokyo has been the unification of all humanity in a single 'heavenly kingdom on earth' where all religions would be united under the banner of omotokyo. It is impossible sufficiently to understand many of O Sensei's writings and sayings without keeping the influence of Omotokyo firmly in mind.
Despite what many people think or claim, there is no unified philosophy of Aikido. What there is, instead, is a disorganized and only partially coherent collection of religious, ethical, and metaphysical beliefs which are only more or less shared by Aikidoists, and which are either transmitted by word of mouth or found in scattered publications about Aikido.
There is still insufficient data available, concerning the full history of Aikido and its origins, and while more will, no doubt be discovered.