Stanojlo Petrović was born in Svine in the Braničevo District of Serbia on 13 February 1813 to an old Serbian family which rose to distinction and imperial favour in the 18th century.
In 1839, Prince Miloš, the man who secured Serbia's autonomy from the Ottoman sultan, was now forced to abdicate and relinquish his throne in favor of his firstborn Milan Obrenović II who by then was terminally ill and died after just one month later.
It is said that in that position he gave evidence of so much natural ability and tact that in 1840 when Mihailo was declared of full age, Captain Stanojlo Petrović was elevated to the rank of Major and made adjutant to the young prince by the abdicating monarch himself.
Meanwhile, Stanojlo Petrović stayed in Belgrade and continued to correspond secretly with the deposed monarch and his father to have the usurpers removed from their posts and have Mihailo returned to his rightful place.
The correspondence fell into the hands of the governing body and Stanojlo was afterwards tried and sent to prison for 10 years in Knjaževac in the notorious dungeon called Gurgušovačka kula.
After two years in solitary confinement and with the help of Russian diplomats, Stanojlo Petrović was released on 17 July 1844 along with a few more Obrenović loyalists who were all pardoned by now-Prince Aleksandar Karađorđević.
Rajačić supported General Josip Jelačić who took an oath to become the counsel of Austrian Emperor Ferdinand I before the hostilities escalated.
The Serbs demanded a national unit consisting of Banat, Bačka, Baranja and part of Srem which would become known collectively as Serbian Vojvodina.
Hungarians were not positive towards the Serbs at this time but support came from the new Austrian emperor Franz Joseph I who approved the establishment of Serbian Vojvodina along with Stevan Šupljikac as Duke (Vojvoda).
Stanojlo (who headed the army of Požarevac at the time and served as adjutant to the commander of the Montenegrin regiment) was sent by Prince Aleksandar Karađorđević to aid the Serbs in Vojvodina.
Some three thousand Serbian soldier volunteers on 15 December 1848 crossed the Danube river and went to Pančevo where Vojvoda Stevan Šupljikac welcomed them.
As a result of the Hungarian Revolution of 1848, the autonomous region of Serbian Vojvodina was established and approved by Franz Joseph, the titular emperor of the Holy Roman Empire at the time.
Two years later (1857), because of a disagreement with the military commander Jovan Lukačević, Petrović asked for a transfer and became commissioner of the Smederevo district, a post held previously by Stevan Knićanin in 1839.
During the Saint Andrew's Day Assembly in 1858, Stevča Mihailović was the leader of the Obrenović faction and led the delegation that demanded the abdication of Prince Aleksandar Karađorđević.
In Belgrade, the national parliament was held in which Aleksandar Karađorđevic was dismissed in favor of Miloš Obrenović who was chosen as a prince.
Prince Miloš immediately promoted Stanojlo to adjutant and government advisor (Privy Council) as well as Deputy Minister of External Affairs.
Stanojlo and Draginja Petrović became prominent figures in Belgrade society and friends of many authors, artists, tradesmen, scientists and politicians.