Commander
By 26 May 1656, he received the position of the chorąży koronny (Standard-bearer of the Crown). During the three-day-long battle of Warsaw of 1656, Sobieski commanded a regiment of 2,000 men of Tatar cavalry. He took part in a number of engagements over the next two years, including the Siege of Toruń in 1658. In 1659, he was elected a deputy to the Sejm (Polish parliament), and was one of the Polish negotiators of the Treaty of Hadiach with the Cossacks. In 1660, he took part in the last offensive against the Swedes in Prussia, and was rewarded with the office of starost of Stryi. Soon afterward he took part in the war against the Russians, participating in the Battle of Slobodyshche and Battle of Lyubar, and later that year he again was one of the negotiators of a new treaty with the Cossacks (the Treaty of Chudnov).
Through personal connections, he became a strong supporter of the French faction in the Polish royal court, represented by Queen Marie Louise Gonzaga. His pro-French allegiance was reinforced in 1665, when he married Marie Casimire d'Arquien and was promoted to the rank of the Crown Grand Marshal.
In 1662, he was again elected a deputy to the Sejm and took part in the work on reforming the military. He was also a member of the Sejm in 1664 and 1665. In between, he participated in the Russian campaign of 1663. Sobieski remained loyal to the King during the Lubomirski Rebellion of 1665–1666, though it was a difficult decision for him. He participated in the Sejm of 1665, and after some delays, accepted the prestigious office of the Marshal of the Crown on 18 May that year. Around late April or early May 1666 he received another high office of the Commonwealth, that of the Field Crown Hetman. Soon afterward, he was defeated at the Battle of Mątwy, and signed the Agreement of Łęgonice on 21 July, which ended the Lubomirski Rebellion.
In October 1667, he achieved another victory over the Cossacks of Petro Doroshenko and their Crimean Tatar allies in the Battle of Podhajce during the Polish–Cossack–Tatar War (1666–1671). This allowed him to regain his image as a skilled military leader. Later that year, in November, his first child, James Louis Sobieski, was born in Paris. On 5 February 1668, he achieved the rank of Grand Hetman of the Crown, the highest military rank in the Polish–Lithuanian Commonwealth, and thereby the de facto commander-in-chief of the entire Polish Army. Later that year he supported the French candidacy of Louis, Grand Condé for the Polish throne, and after this candidacy fell apart, Philip William, Elector Palatine. Following the election of Michał Korybut Wiśniowiecki he joined the opposition faction; he and his allies helped veto several sejms (including the coronation ones), and his attitude once again resulted in him losing popularity among the regular szlachta. While his pro-French stance in politics alienated some, his military victories against invading Tatars in 1671 helped him gain other allies.
The year 1672 saw internal politics destabilising the Commonwealth, as the pro-French faction of Sobieski and the pro-court faction of King Michał formed two Confederations (konfederacja), which, despite major Ottoman incursions in the south, seemed more concerned with one another than with uniting to defend the country. The court faction called openly for confiscation of his estates and dismissal from office, and declared him an "enemy of the state". This division culminated in the humiliating Treaty of Buchach, where the Commonwealth was forced to cede territories to the Ottomans, but promise an annual tribute. Sobieski eventually succeeded in balancing politics and national defense, and a combination of his military victories over the invaders, and successful negotiations at the Sejm in April 1673, led to a compromise in which the court faction dropped its demands and challenges against him.
In the year 1672, the Polish-Lithuanian Tatars rose up in open rebellion against the Commonwealth. This was the widely remembered Lipka rebellion. Thanks to the efforts of Sobieski, who was held in great esteem by the Tatar soldiers, many of the Lipkas seeking asylum and service in the Ottoman Army returned to his command.
On 11 November 1673, Sobieski added a major victory to his list, this time defeating the Ottomans in the Battle of Khotyn (Chocim) and capturing the fortress located there. The news of the battle coincided with the death of King Michal the day before the battle. This made Sobieski one of the leading figures of the state, so on 19 May the following year, he was elected monarch of the Commonwealth. His candidacy was almost universally supported, with only a dozen or so members of the diet opposing him (mainly centered around magnates of the Lithuanian Pac family). In light of the war, requiring Sobieski to be on the front lines, the coronation ceremony was significantly delayed – he was crowned John III almost two years later, on 2 February 1676.