History’s only armed spacecraft (so far as we know)
In 1971 the Soviet military initiated the Almaz project, a highly secretive project to place orbital space stations around the Earth whose mission was to spy on the Soviet Union’s Cold War enemies. The project consisted of Salyut space stations, technically civilian stations but modified for a military purpose as each station was equipped with powerful cameras, some of which could photograph objects on Earth at a resolution of 1 meter. Three Salyut stations were launched as part of the Almaz program between 1973 and 1976; Salyut 2, Salyut 3, and Salyut 5.
Interestingly, Salyut 3 was special in that it was the only known spacecraft to be armed with a gun. On the belly of the station was mounted a 23mm Rikhter R-23 anti aircraft cannon. Typically mounted on the Soviet TU-22 bomber, the gun was a gas operated revolving cannon that could fire at a rate 1,800 - 2,000 rounds per minute. It was intended to fend off a possible attack by the Americans or capitalist space aliens. Placed on a fixed mount, in order to aim the weapon the entire station had to be manuevered toward its target. The cannon was only fired once towards the end of Salyut 3’s mission while the station was unmanned. After blasting a target satellite during the test fire, it was found that in the zero gravity environment of space the recoil of the gun rocked the station causing it to tumble.
Due to a malfunctioning docking system, it became impossible to resupply the station. Thus, it was decided to end Solyut 3’s mission and the station was abanondoned. It reentered the atmosphere and burned up on the 24th of January, 1975. The Almaz project was canceled in 1976 due to costs, and the effectiveness of new spy sattelite technology.