According to Turkish records, Kara Mustafa was born in the Islamic year 1044 (1634 C.E.). From his name Merzifonlu, we can determine that he was born in or near the city of Merzifon (modern Merzovan, Turkey). He was the son of a Turkish sipahi (knight) and rose through the ranks of the Ottoman military and government structure.
Mustafa is universally described in contemporary Christian sources as both greedy and villainous. The veracity of this is naturally open to conjecture, although his nickname of Kara (black} can be interpreted in many ways.
He was adopted into the powerful Köprülü family at a young age, and served as a messenger for Köprülü Ahmed, the powerful grand vizier of Damascus. After distinguishing himself, Mustafa became a vizier in his own right, and by 1663, commander of the Ottoman Grand Fleet of the Aegean Sea.
He served as a commander of ground troops in a war against Poland in 1672, negotiating a peace settlement that added the province of Podolia to the empire. The victory enabled the Ottomans to transform the Cossack regions of the southern Ukraine into a protectorate. In 1676, when the grand vizier died, Mustafa succeeded him.
He was less successful in combatting a Cossack rebellion that began in 1678. After some initial victories, intervention by Russia turned the tide and forced the Turks to conclude peace in 1681, effectively returning the Cossack lands to Russian rule with the exception of a few forts on the Dnieper and Bug rivers.
In 1683, he launched a campaign northward into Austria in an effort to put a final end to more than 150 years of war. By mid-July, his 140,000-man army had invested Vienna, following in the footsteps of Suleiman the Magnificent in 1529. By September, he had taken a portion of the walls and appeared to be on his way to victory.
But on September 12, 1683, the Austrians and their Polish allies under King Jan Sobieski took advantage of Mustafa's poor disposition of his troops and won the Battle of Vienna with a devastating flank attack led by Sobieski's Polish cavalry. The Turks retreated into Hungary, never again to threaten central Europe.