The military of the Ryukyu Kingdom defended the kingdom from 1429 until 1879. It had roots in the late army of Chà «zan, which became the Ryukyu Kingdom under the leadership of King Shà  Hashi. The Ryukyuan military operated throughout the Ryukyu Islands, the East China Sea, and elsewhere that Ryukyuan ships went, including the South China Sea and further west, along the maritime silk road. Ryukyu primarily fought with other Ryukyuan kingdoms and chiefdoms, but also Japanese samurai from Satsuma Domain and pirates. Soldiers were stationed aboard ships and Ryukyuan fortifications. The Ryukyuan military declined after the 17th century until it was abolished following the Japanese annexation of Ryukyu in 1879.
Chà «zan Seikan, the first official history of Ryukyu, details the military victories of Shà  Hashi. He first captured à Âzato Castle in 1403, then overthrew King Bunei of Chà «zan in 1407, installing his father as king. He moved the capital from Urasoe to Shuri. During the early 1410s, aji, Ryukyuan feudal lords, under the rule of Hokuzan got into a dispute with their king, Hananchi. On 11 March 1422, Shà  Hashi gathered the forces of the ajis of Urasoe, Goeku, and Yomitanzan at Shuri. He convinced the ajis of Nago, Kunigami, and Haneji to join him, then he marched his forces to Nago. At Nago, Shà  Hashi's force of 500 attacked a castle, defeating its 200 defenders. Upon reaching Nakijin Castle, Shà  Hashi sent 20 infiltrators to set fires and open the castle gates. Hananchi committed suicide, and Shà  Hashi had conquered Hokuzan. Shà  Hashi allowed Gosamaru, Yomitanzan Aji, to build Zakimi Castle for supporting him in the war. According to Chà «zan Seifu, a succession dispute broke out when the king of Nanzan, Taromai, died in 1429, prompting Shà  Hashi to march south and conquer the kingdom, finally unifying Okinawa Island as the Ryukyu Kingdom.
There are indications that Ryukyu invaded the Amami Islands during the 1440s, but in 1450 sailors from Korea were shipwrecked on Gaja Island, where they found the island half occupied by Ryukyu and half occupied by Satsuma Domain of Southern Japan. Gaja Island is about north of Naze, the principal settlement on Amami à Âshima, and south of Kagoshima City, the capital of Satsuma.
After a violent succession dispute in 1453, Shà  Taikyà « became king. Amawari, who had overthrown the Katsuren Aji, worried the king with his wealth and military strength. The king asked Gosamaru to build Nakagusuku Castle in a location between the royal palace at Shuri Castle and Katsuren Castle. After the castle was built, Gosamaru started to mobilize his forces. Amawari told the king that Gosamaru was plotting a rebellion, to which the king ordered an attack on Nakagusuku Castle. Gosamaru committed suicide and his castle fell; the king then ordered Uni-Ufugusuku to lead an army against Katsuren Castle, where Amawari was defeated and executed. Uni-Ufugusuku was awarded and built Chibana Castle.
In 1466, King Shà  Toku launched an invasion of Kikai Island in the Amami Islands with 2,000 soldiers and 50 ships. Satsuma launched an invasion of Amami à Âshima in 1493, but Ryukyu defeated Satsuma. Rebellions in Amami à Âshima were put down in 1537, 1538, and 1571. Additionally, there were pirate attacks on Naha in 1553, 1556, and 1606 where the port was successfully defended.
During the reign of Shà  Shin (r. 1477âÂÂ1537), the military was completely reorganized. This included the development of the system, which had been the basic military unit since Shà  Hashi. Shà  Shin turned them into a quick reaction force with military, police, and administrative duties. He confiscated weapons from the peasantry, then forced the aji to relocate to his capital to minimize the chances of rebellion and to centralize the military under total royal control. After 1522, the ajis armies, called , became known as . Also in 1522, Shà  Shin had the constructed between Naha and Shuri to allow quicker troop movement between the port and the royal palace, which was then extended by his son, Shà  Sei, to connect Tomigusuku, Mie, and Yarazamori Castle in 1546.
In April 1609, Satsuma Domain launched a second invasion of the Ryukyu Kingdom. Within a month, they conquered the Amami Islands in the face of fierce resistance on all but Okinoerabu Island. After Satsuma landed on Kouri Island, across from Unten Harbor, Ryukyu sent a thousand soldiers, commanded by Nago Ryà Âhà Â, to reinforce Nakijin Castle. On 30 April, Nago Ryà Âhà Â's force met the Satsuma army near Nakijin, but retreated after sustaining a 50% casualty rate; Nakijin was captured and razed and Shà  Kokushi, the garrison commander and the heir to the Ryukyuan throne, died from wounds sustained in the battle. Satsuma landed in Yomitanzan unopposed on 3 May, advancing overland towards Shuri and by sea towards Naha. Ryukyu was able to stop and drive Satsuma away from Naha, but Satsuma was able to capture Urasoe Castle and cross the Taihei Bridge, surrounding Shuri Castle. After fierce resistance, Shuri fell on 6 May and King Shà  Nei surrendered.
After the disastrous war, Ryukyu was forced to cede the Amami Islands and become a vassal of Satsuma. Jana Ueekata, who had commanded the defense of Naha, was executed for refusing to sign the peace treaty. While the hiki system was reduced in status during the 17th century, Ryukyu's military remained to defend the country and its tribute ships from pirates in the East China Sea. For example, hundreds of Ryukyuan soldiers were mobilized in 1640 when foreign ships were spotted near the Yaeyama Islands, and there is documentation of Ryukyuans defeating pirates as late as the turn of the 19th century.
In 1871, a tribute ship was shipwrecked on Taiwan, and the crew was slaughtered by Taiwanese aborigines in the Mudan Incident. The following year, the Meiji government informed the royal government that the kingdom was then a domain of Japan (as Ryukyu Domain). In 1874, Japan invaded Taiwan on behalf of the Ryukyuans. After the royal government resisted and disobeyed the Meiji government, 400 Japanese soldiers landed at Naha in March 1879 with a demand that King Shà  Tai abdicate. After a few days the Japanese occupied Shuri Castle, and the deposed king was taken to Tokyo. Ryukyu was annexed and Okinawa Prefecture was established.
The Ryukyuan military hierarchy was a top-down chain of command, with the king at the top. Below the king was the Sanshikan, a government body of his three most trusted advisors. There were three , each of which composed of four hiki, that guarded the Shuri-Naha area. Historian Gregory Smits concludes that the Sanshikan originated from the commanders of the three Watches. In addition to the Watches, each magiri had forces of an unknown size, as well as the 17 or so Ryukyuan castles that were manned and Ryukyuan ships that were defended by an onboard hiki. The hiki themselves were further broken down by rank: the hiki was commanded by a ; below the Sedo was the rank of , followed by , and at the bottom was .
The Ryukyuan military used a combination of imported weapons from China and Japan, often modified, and some domestically made weapons. The most common Chinese imports were guns and cannons, especially multi-barreled guns known as hand cannons. Japanese swords, especially the wakizashi, were highly sought after, and were usually modified to allow for better one-handed use to wield a shield. Both Chinese-style and Japanese-style halberds were also widely used.
Ryukyu also made use of junks at sea. Ryukyuan ships were defended by soldiers and armed with cannons; fleets of nearly 100 junks were used during some of Ryukyu's military campaigns. Ryukyuan ships continued to officially operate until 1875.
The origins of karate (Okinawan: tii), kobudà Â, and tegumi are often attributed either to Ryukyu's military or nobility. Common myths state that karate developed because of confiscations of or bans on weapons by King Shà  Shin and Satsuma Domain, respectively. However, Uni-Ufugusuku (d. 1469) was known for his skills in tii.