During his long lifetime Mikhail Kalashnikov expressed few regrets about his deadly eponymous invention. "I sleep soundly," he once said.

But in a letter to the head of Russia's Orthodox church written shortly before his death, the creator of the AK-47 revealed he was lately afflicted with spiritual torment. Kalashnikov, who died last month aged 94, told Patriarch Kirill he felt responsible for the millions of deaths caused by his revolutionary sub-machine gun.

"My spiritual pain is unbearable. I keep asking the same insoluble question. If my rifle deprived people of life then can it be that I … a Christian and an orthodox believer, was to blame for their deaths?" he wondered.

The letter, written last April and published on Monday by the newspaper Izvestia, is filled with similar musings about the nature of good and evil and the meaning of life.

"The longer I live," he wrote, "the more this question drills itself into my brain and the more I wonder why the Lord allowed man the devilish desires of envy, greed and aggression."

He also ponders the state of Russia. "Yes! An increasing number of churches and monasteries in our land. And yet evil does not decrease! … Light and shadow, good and evil, two opposites of a whole, that can't exist without each other?"

Previously, in numerous interviews, Kalashnikov shrugged off questions of personal responsibility for his ubiquitous weapon, which he designed for the Red Army in 1947. His rifle went on to become the most prolific killing machine ever invented, used by regular and irregular forces, as well as terrorists, narco-gangs and others. The number of people killed with it amounts to many millions, with the rifle featuring in virtually every conflict. Kalashnikov insisted that it was politics, and not his superlative work as a designer, that was to blame.

Like most Soviet citizens of his generation, Kalashnikov grew up without any formal faith. He embraced the Russian Orthodox church in his declining years while living – and very deaf – with his daughter Elena, and grand-daughter Ilona, at his home in Izhevsk in the south Urals countryside. Elena Kalashnikova said on Monday she hadn't helped her father compose his letter, typed up on two pages and signed shakily: "Slave of God, designer Mikhail Kalashnikov." A local priest had helped him write it, she suggested.

According to Izvestia, the patriarch wrote back to Kalashnikov and offered him some spiritual comfort. In his reply, he praised Kalashnikov as an example of a patriot who had the right attitude towards his country.

"The church has a very definite position: when weapons serve to protect the Fatherland, the Church supports both its creators and the soldiers who use it," the patriarch's spokesman, Alexander Volkov said, adding: "He [Kalashnikov] designed this rifle to defend his country, not so terrorists could use it in Saudi Arabia."

Kalashnikov died in hospital on 23 December, a month after he was admitted with internal bleeding. His missive of repentance features a photo of him dressed in his military uniform encrusted with medals. On his 75th birthday he was promoted to the rank of general. President Vladimir Putin led mourning at his funeral.

In his letter, Kalashnikov describes his creation as a "miracle weapon". He also had some unexpected words of praise for the Soviet Union's main cold war rival. Despite different ideological and social systems, the Americans were "friends", he wrote.