Development of the weapon that would eventually become the very successful 1902 Madsen light machine gun began many years earlier, in 1883. Two Danes, Madsen and Rasmussen, began working on a recoil-operated self loading rifle design that year, with Madsen developing the idea and Rasmussen fabricating the actual pieces. The project was made difficult by the black powder cartridges available at that time (black powder fouled intricate mechanics quickly, and also created a relatively poor recoil impulse compared to later smokeless powders), but by 1887 they had a workable gun completed. This rifle, designated the M1888 Forsøgsrekylgevær, was entered into Danish military testing, and went so far as to have 50 rifles field-tested by a battalion of troops. The conclusion was that the design wasn’t good enough for infantry use (although it was considered for fortress use, which would presumably be a cleaner environment that being in the hands of field infantry units), and the Krag-Jørgensen was selected instead for general issue.
Note the very small bayonet, typical of recoil-operated rifles in which too heavy a bayonet will cause the rifle to malfunction by increasing the weight of the reciprocating barrel assembly (the M1941 Johnson rifle was also recoil operated and used a similar style bayonet). As testing progressed, stacking swivels were added to the guns.