And if yes, was it considered dishonorable for kings or lords to hire them?
Far from being in medieval times, mercenaries have been a critical part of militaries from ancient times up to the Napoleonic Era (and even after in other parts of the world). One could even argue that mercenaries were the driving factors behind the professionalization and standardization of armies across the late medieval and early modern periods. At some points, such as during the 30 Years War, virtually the entire armed forces of combatants were composed by mercenaries, commanded by mercenaries, and administered by mercenaries, all under a mercenary general!
Part of the problem with raising a standing army was the high cost. The nature of the feudal system meant that nobles simply could not afford to maintain armies for long campaigns, or even for peacetime duties. Aside from whatever levies could be raised from one's demesne, the main method of recruiting experienced troops on short notice was by recruiting mercenary free companies.
The problem with general levied troops was that for the most part they had little combat experience and training, aside from of course noble cavalry (which were even more expensive to maintain). In an era when heavy cavalry was one of the most powerful elements in an army, having troops that were disciplined enough to resist a cavalry charge was viewed as a critical component to battlefield success. Free companies were thus a valuable component to any medieval army, and in some cases these mercenary bands would be incorporated directly into the military-essentially acting as the army. Though they were certainly expensive as well, they could be dismissed when they were no longer needed, and there was an implicit understanding that the mercenaries had looting rights after a siege or a victorious battle whereupon they could seize the enemy's baggage train, not to mention whatever ransom they could get from captured prisoners, especially nobles.
As the mercenary profession grew to be more and more prevalent, the nature of their business changed as well. For, as it turned out, maintaining a full set of personnel and going from fief to fief looking for business was also quite expensive. The Italian institution of condottieri (essentially, contractor or military contractor) was an innovation to help combat this: rather than simply going around looking for work, the condottieri provided a turnkey solution to the Italian city state's needs for national defense. Essentially the city state would contract out all their military needs to the condottieri.
One can obviously imagine that this left the condottieri with a great deal of leverage over the city states (which they promptly took advantage of more often than not) but this also facilitated a new wave of military science, as the condottieri sought to find ways to maximize the efficiency of their armies (reducing logistical costs, developing tactical innovations in order to avoid expensive casualties, and so forth) in order to save money. This began to change the nature of warfare away from pitched battle (which would usually result in mass casualties, which is expensive) and towards siege and counter-siege (which avoided combat and thus losses, while at the same time offering the great prospect of loot after capturing a city or town).
The Italians were not alone in this mercenary-driven renaissance: the Swiss pikemen and later German landsknechten were similar innovations to help solve military problems. In some cases, this could end poorly: for instance, the Battle of Pavia which decisively ended the Italian Wars led to a French defeat after over half of the Swiss mercenaries in the employ of the French deserted prior to the battle due to missed pay as well as the threat of-you guessed it-other roaming mercenaries that were pillaging Swiss lands. But rather than lead to a general disuse of mercenaries, it just caused early modern leaders to tie mercenaries closer to their own national interests: one of the most infamous mercenaries of the 1600s, Albrecht von Wallenstein, essentially commanded the entire armies of the Holy Roman Empire (including his own direct mercenaries as well as other such groups) and was paid by essentially having the right to rule Bohemia and collect its taxes. The 30 Years War is often portrayed as an event in where all Europe proceeded to invade and interfere in Germany, but in reality the armies of all combatants contained large numbers-if not outright majorities-of German mercenaries (Catholics and Protestants together, more often than not).
All-in-all, mercenary armies were the norm, rather than a rare sight in the armies of Europe up until the modern era. The problem was that the line between mercenary and nation-state could blur to the point of extremity. The best example of this is the subject of Machiavelli's The Prince, Duke Sforza of Milan, who was a mercenary captain that fought for the Duke of Milan, then against the Duke of Milan, then for the Duke of Milan again, then married the Duke of Milan's daughter.
Oh, but we're not finished. After the Duke of Milan died without an heir, and the Milanese promptly proclaimed a republic, Sforza was hired by the republic to defend against outside threats. After smashing a set of Venetian armies, Sforza suspected that the Milanese had betrayed him and promptly switched sides to the Venetians. He then lay siege to Milan (after defeating a Venetian army that was sent after the Venetians realized having Sforza ruling Milan may have been a bad idea) and became the new Duke of Milan after the city capitulated.
Mercenaries, not even once.