She was the Tsaritsa of Russia from 1671–1676 as the second spouse of Tsar Alexei I of Russia, and as such the mother of Tsar Peter I of Russia. She came from a petty noble family, daughter of Kirill Poluektovich Naryshkin (1623–1691) and wife Anna Leontyevna Leontyeva (d. 1706, daughter of Leonty Dimitriyevich Leontyev and spouse Praskovya Ivanovna Rayevskaya who died in 1641), she was brought up in the house of the great Western-leaning boyar Artamon Matveyev. She was given a freer and more Western-influenced upbringing than most Russian women of the time. She married Tsar Alexei Mikhailovich as his second spouse. They had three children, the future Emperor Peter I of Russia (1672–1725); Tsarevna Natalya who founded the first public theatre in Russia, writing a number of its plays herself; and Tsarevna Theodora (Feodora). After the throne was secured for her son Peter, Natalya, her brothers, and the patriarch effectively controlled the government. She became widowed when Tsar Alexei died in 1676; a son from his previous marriage ascended the throne as Tsar Feodor. Feodor and brother Ivan treated their stepmother with affection, always referring to her as "Mama". When Feodor died in 1682, her 10-year old son became Tsar Peter the Great. With Sofia heading the regime of her son Peter as a co-Tsar, she lived in poverty, receiving financial support from the Patriarch or others in the Orthodox Church. She spent her time mainly in Alexei's summer palace in Preobrazhenskoe, about 5 km from Moscow, together with her son Peter. In August 1689, Peter overthrew Sofia, and he and his half-brother Ivan continued to be co-Tsars. She was back as nominal leader in the court. When the Patriarch Joachim died in 1690, Peter wanted to appoint Marcellus, Bishop of Pskov, who had travelled overseas and spoke several languages, as the new patriarch. However, She led the conservative faction in the court to nominate the conservative Adrian, Bishop of Kazan, to head the Russian Orthodox Church.