During the Ming Dynasty (1368–1644), the Mongols enrolled in military service were either originally prisoners of war or they were those who voluntarily submitted to the Ming and settled in China. Others fled their homeland on the northern steppe due to natural disasters such as droughts, seeking refuge in China where Mongol families found lodging and hospitality. Some Mongols became distinguished military officers, were granted noble ranks, and on rarer occasions became ministers in the state bureaucracy. Mongols of noble lineage socialized with Chinese literati of the two capitals (Nanjing and Beijing) while they also had their sons educated in the Chinese classic texts. Nonetheless, Mongols in the Ming Empire were often held in suspicion by Chinese Ming authorities. Mongols of lower social stature were often accused by Chinese officials of being prone to violence, banditry, and becoming beggars and even prostitutes. Ming officials used the excuse of military campaigns to relocate and scatter Mongol troops and families throughout China so that they would not be concentrated in North China (which neighbored the enemy territory of the Mongol heartland). Wu Tingyun argues that there was a noticeable shift in Ming court policies after the 1449 Tumu Crisis in dealing with the Mongols; he stated that beforehand the Ming court actively encouraged Mongol immigration, and afterwards merely managed those who had already sided with the Ming.
On July 20, 1461, after Mongols had staged raids in June into Ming territory along the northern tracts of the Yellow River, the Minister of War Ma Ang (马昂; 1399–1476) and General Sun Tang (孙镗; d. 1471) were appointed to lead a force of 15,000 troops to bolster the defenses of Shaanxi. Historian David M. Robinson states that "these developments must also have fed suspicion about Mongols living in North China, which in turn exacerbated Mongol feelings of insecurity. However, no direct link can be found between the decision by the Ming Mongols in Beijing to join the  coup and activities of steppe Mongols in the northwest."
On August 6, 1461, the Tianshun Emperor issued an edict telling his nobles and generals to be loyal to the throne; this was in effect a veiled threat to Cao Qin, after the latter had his associate in the Imperial Guard murdered to cover up crimes of illegal foreign transactions. This soldier in the imperial guard had acted as Cao's private commercial agent, but when this man failed to keep affairs secret, Cao had the soldier's wife tell authorities that her husband had gone mad and fled. Lu Gao (逯杲; d. 1461), head officer of the Imperial Guard, had authorities apprehend the missing soldier with approval of the Emperor, whereupon Cao had his former commercial agent beaten to death before authorities could reach him.
The General Shi Heng (石亨; d. 1459), who aided Tianshun's succession, starved to death in prison after a similar warning from an imperial edict; his son Shi Biao (石彪) was executed in 1460. Cao Qin was to take no chances in allowing himself to be ruined in similar fashion. Cao's Mongol troops were veterans who had fought in several campaigns under the eunuch Cao Jixiang (曹吉祥)—Cao Qin's adoptive father—in the 1440s. The loyalty of Cao's Mongol-officer clients was secure due to circumstances of thousands of military officers who had to accept demotions in 1457 because of earlier promotions in aiding Jingtai's succession. Robinson states that "Mongol officers no doubt expected that if Cao fell from power, they would soon follow."
Cao either planned to kill Ma Ang and Sun Tang as they were to depart the capital with 15,000 troops to Shaanxi on the morning of August 7, or he simply planned to take advantage of their leave. The conspirators are said to have planned to place their heir apparent on the throne and demote Tianshun's position to "grand senior emperor", the title delegated to him during the years of his house arrest from 1450 to 1457, under Jingtai's rule.
While Cao held a banquet for his Mongol officers on the night of August 6, two of his Mongol officers slipped away from the festivity and leaked Cao's plot to the high-level Mongol commanders Wu Jin (吴瑾) and Wu Cong (吴琮) around 1:00 am to 3:00 am in the morning of August 7. Wu Jin alerted General Sun Tang about the plot, and soon after Sun alerted the emperor with a message slipped through the Western Chang'an Gate. Upon receiving this warning, the Emperor arrested the eunuch conspirator Cao Jixiang and had all nine gates of Beijing and all four gates of the Forbidden City blockaded. Meanwhile, Cao Qin began to suspect that the plot was leaked, and so moved with his troops around 5:00 to 7:00 am in the morning of August 7 to inspect the gates of the Imperial City; when the Dongan Gate (the eastern entrance) failed to open, his suspicions were confirmed.
While his forces searched for Ma Ang and Sun Tang, Cao visited the home of Lu Gao, head of the Imperial Guard who led the efforts to investigate Cao Jixiang and Cao Qin, and killed Lu in his own home (decapitating and dismembering him). After killing Lu Gao, Cao Qin found and detained the Grand Secretary Li Xian (李贤; 1408–1467), showing him the severed head of Lu Gao and explaining that Lu had driven him to rebellion. Li Xian agreed to draft a memorial to the throne explaining that Cao Qin wished the emperor no harm, that his vengeance against Lu Gao was finished, and asked for an imperial pardon. Cao's men had also detained the Minister of Personnel, Wang Ao (王翱; 1384–1467), and using writing materials from his office Li and Wang composed the memorial. Wang and Li slipped the message through the door panels of the gate to the Imperial City, but the gates remained tightly shut, so Cao Qin began calling for the death of Li Xian. Wang Ao and Wan Qi (万祺; d. 1484), a director of the Ministry of Personnel, dissuaded Cao Qin from killing Li, noting Li had written the funerary inscription for Cao's adopted father Jixiang.
After Li's message was unable to get through, Cao Qin began the assault on Dongan Gate, East Chang'an Gate and West Chang'an Gate, setting fire to the western and eastern gates; these fires were extinguished later in the day by pouring rain. Defending these gates were 5,610 imperial bodyguards, who were generously rewarded after the conflict for their merit in maintaining a strong defense. Ming troops poured into the area outside the Imperial City to counterattack; Li Xian and Wang Ao were able to flee, but Wu Jin and the head of the Censorate, Kou Shen (寇深; 1391–1461), were killed by Cao's soldiers. Kou had earlier denounced Cao as a criminal and was an associate of Lu Gao; when Cao's soldiers found Kou in a waiting room outside Chang'an Gate, he cursed at them before they cut him down.
General Sun led the charge against Cao Qin right outside Donghua Gate, while Ma Ang approached Cao Qin's forces from the rear in a flank. Cao was forced to withdraw and set up temporary camp at Dongan Gate. By midday, Sun Tang's forces had killed two of Cao Qin's brothers (Sun personally shot the second with an arrow after Cao Qin's brother led cavalry charges against imperial troops). Sun's forces had also severely wounded Cao Qin in both his arms; his forces took up position in the Great Eastern Market and Lantern Market northeast of Dongan Gate, while Sun deployed artillery units against the rebels. Cao lost his third brother, Cao Duo (曹铎), while attempting to flee out of Beijing by the Chaoyang Gate. Cao made another dash for the northeastern gates of the capital (Anding Gate and Dongzhi Gate), and then back to Chaoyang Gate, all of which remained closed. Finally, Cao fled with his remaining forces to fortify his residential compound in Beijing. Ming troops under Sun Tang and the newly arrived Marquis of Huichang, Sun Jizong (孙继宗), stormed the residence. To avoid arrest and execution, Cao Qin committed suicide by throwing himself down a well. Imperial troops recovered his body and then decapitated it.
As promised by Grand Secretary Li Xian before the final assault on the Cao residence, imperial troops were allowed to confiscate for themselves what they could find from Cao Qin's property. Li had also given another incentive that any imperial soldier who captured a rebel would be rewarded with the same title and office their captive had. Those found to be followers of Cao Qin were soon after executed, including members of the Imperial Guard and the Yuzhou Guard on August 22, 1461. On August 8, Cao Jixiang was publicly dismembered, a sentence and execution which ministers of state were made aware of by the Tianshun Emperor once he held an audience at the Median Gate. The dismembered corpses of Cao Qin and his brothers were left outside and exposed to the elements. Cao's father-in-law was spared from punishment since it was known that he had refused to communicate with Cao Qin during the latter's rise to power as a career general.
The Tianshun Emperor spared some of the culprits the sentence of death by commuting their sentence to imprisonment instead; this included Vice Commissioner-in-chief Esen Temür, who lowered himself down the city walls of Beijing and was later found in a farmer's melon patch as far as Tongzhou District. Others were exiled to Lingnan to "suffer the inhospitable tropical climate for the remainder of their lives," according to Robinson. Li Xian also pressured the Emperor to pardon and exonerate "those who had been forced to join" Cao's rebellion.
Rewards were given to those who captured the escapees of the plot, including Chen Kui, Grand Defender of Tianjin, who was promoted. On August 9, the Mongol officer Wu Cong was put in charge of the Chief Military Commission of the Left; in September, twenty taels of silver and two-hundred piculs of grain were added to his stipend. Ma Ang was made the Junior Guardian of the Heir Apparent in September. Plaques were made to commemorate the dead who fought against Cao Qin.
Besides the handling of punishments and rewards, the court made other efforts to reestablish order in the capital region. Nonessential taxes were suspended. Nobles of the imperial clan patrolled the gates of the imperial city while rebels were still at large. Some residents in Beijing abused the order that they alert authorities of remaining culprits of the coup in order to label personal enemies as "rebels" to take their property. To discourage this, the emperor had several dozen of these looters beaten and paraded through the streets as criminals. In an edict of August 9, the Emperor reassured loyal Mongol officers of Baoding that Mongol participation in Cao's rebellion did not mean persecution for them. In October, Mi Duo-duo-lai, commander of Baoding and veteran Mongol officer who fought against Esen Tayisi's 1449 invasion, was ordered to stay put in Baoding, a gesture by the emperor that there was no need to worry about loss of authority.
Three weeks after Cao Qin's failed uprising, the Mongol leader Bolai, who had been staging raids into northern China, sent an embassy into China to request formal tribute relations and to serve as a vassal to the Ming. News of this rebellion reached the Joseon court of Korea by September 9, while the Korean official in charge of the report perhaps embellished the level of gore and violence by stating that tens of thousands had died and the three days of pouring rain following the rebellion flooded even the Forbidden City with streams of blood and rain. A native rebellion would not threaten the capital city again until the fall of Beijing to the army of Li Zicheng in 1644, marking the end of the dynasty and, shortly after, the beginning of Manchu conquest. Until the conquest of the Manchu Qing Dynasty, Chinese officials continued to show a large degree of apprehension over Mongols in military service to the Ming, and still favored relocation schemes. However, Cao's rebellion marked the last event when Ming Mongols were of great importance to court affairs; although many Mongol officers retained hereditary titles of noble lineage, the nobility within the military command structure declined as a whole while men from more humble origins eventually displaced them.
The general Chinese history texts on the Ming Dynasty, including the Mingdai Shi and the Mingshi, briefly mention Cao Qin's failed coup of 1461. Cao Qin's coup and the events leading up to it were covered in Gao Dai's Hong you lu of 1573, Jiao Hong's Guochao Xianzheng lu of 1594–1616, the Huang Ming shi gai of 1632 and the Mingshi jishi benmo of 1658. Li Xian also wrote about Cao Jixiang's career in his "Cao Jixiang zhi bian," featured in the Huang Ming mingchen jingji lu that was edited by Huang Xun in 1551.
The historian Meng Sen (1868–1938), who compiled, edited, and commented on texts dealing with the Ming and Qing eras, stressed that Tianshun was an incompetent ruler for having allowed Shi Heng and Cao Jixiang to develop into formidable threats to central rule. Henry Serruys, whom Robinson calls "the most authoritative writer on the Ming Mongols", did not mention this rebellion in any of his written works. Historians Tang Gang and Nan Bingwen remark in their 1985 publication of the Mingshi that the 1461 coup weakened the power of Ming rule. The historian David M. Robinson devoted the article Politics, Force and Ethnicity in Ming China to the subject of Cao Qin's rebellion and the Ming Mongols. The historian Okuyama Norio wrote an essay in 1977 arguing that Cao Qin's coup of 1461 should be understood as a single event in the wider context of continuous power struggles between civil officials and military officers during Tianshun's reign.