First Irish Sea campaign
Magnus sought to re-establish Norwegian influence around the Irish Sea. He attempted to install vassal king Ingemund in the Southern Isles in 1097, but the latter was killed in a revolt. It is unclear what Magnus's ultimate ambitions were, and the significance of his campaign has been downplayed by modern English historians. English chronicler William of Malmesbury believed that Magnus sought to capture the throne from William II of England (in common with the ambitions of his grandfather, Harald Hardrada). Historians have speculated that he wanted to establish an empire which included Scotland and Ireland, although most modern Norwegian and Scottish historians believe his chief aim was simply to control the Norse communities around the Irish Sea. While he may have been influenced by Ingemund's murder, the Orkneyinga saga claims that Magnus was persuaded by a son of an Orkney earl, Haakon Paulsson, who wanted an earldom for himself. It is also possible that Magnus wished to provide a realm outside Norway for his eight-year-old son Sigurd, who accompanied him. Magnus sailed into the Western Sea in 1098, arriving in Orkney with a large fleet. The Chronicles of the Kings of Mann and the Isles claim that he had 160 ships, but English chronicler Orderic Vitalis states that his fleet consisted of 60 ships. Based on this, P. A. Munch suggests an initial fleet of 160 ships, of which 100 were from the leidang (public levy) and returned shortly after arrival; the fleet accompanying Magnus southward in the campaigns consisted of 60 royal and baronial ships. According to Førsund, the low estimate of 120 men per ship means 8,000 men in the royal and baronial ships and 12,000 from the leidang ships. However, many historians believe that ship numbers in old naval campaign accounts are exaggerated.
After his arrival, Magnus began negotiations with Scottish and Irish kings about the hird and control of land in Scotland, Ireland and the surrounding islands. Upon arriving in Orkney, he sent the earls Paul and Erlend Thorfinnsson away to Norway as prisoners on a leidang ship, took their sons Haakon Paulsson, Magnus Erlendsson and Erling Erlendsson as hostages and installed his own son Sigurd as earl. Magnus then raided Scotland, the Southern Isles and Lewis. Meeting no significant opposition, he continued pillaging the Hebridean islands of Uist, Skye, Tiree, Mull and Islay, and the peninsula of Kintyre; Iona was visited, but not pillaged. Magnus is also recorded as warring in Sanday, although the exact location is unclear (there are three islands with that name in the region). On entering the Irish Sea, he lost three leidang ships and 120 men in Ulster. Magnus then continued to Mann, where the earl Óttar fell in a violent battle; he also chased (or captured) Lagman Godredsson, King of the Isles. Mann came under Norwegian control, and Magnus and his men stayed on the island for a time. During his time there, he organised Norwegian immigration to the island and had several forts and houses built (or rebuilt) using timber from Galloway on the Scottish mainland. This implied he had subdued part of that region too, reducing its chieftains to tributaries.
Magnus may have intended to invade Ireland next, only to find he had overextended himself. He may have been approached by Gruffudd ap Cynan, King of Gwynedd, who had been driven to Ireland by the Norman earls Hugh of Montgomery and Hugh d'Avranches. With six ships (according to Orderic Vitalis), Magnus steered towards Anglesey in Gwynedd, Wales. Appearing off the coast at Puffin Island, he interrupted a Norman victory celebration after their defeat of the Gwynedd king—for the Welsh, "so opportunely it was ascribed to divine providence" according to historian Rosemary Power (although Magnus had not necessarily intended to side with them). In the ensuing battle (known as the Battle of Anglesey Sound, according to Power "the most widely reported event in the history of Magnus"), Magnus shot Hugh of Montgomery dead with an arrow through his eye and defeated the Norman forces. The sources indicate that Magnus regretted killing Montgomery, suggesting that he may have been interested in an alliance with the Normans. He abruptly returned to Mann with his men, leaving the Norman army weak and demoralized. After this battle, Anglesey was considered the southern border of Norway. Gruffudd ap Cynan soon returned to the island, awarding Magnus gifts and honour (which may indicate that Gwynedd had capitulated). The extension of Magnus's kingdom probably began to concern the English, who remembered the invasion of Magnus's grandfather Harald Hardrada in 1066, war with Danish king Sweyn II Estridson in 1069–70 and the threat of invasion by Cnut IV in 1085.
In Scotland internal fighting continued between rival kings, although King Edgar had gained a slight advantage. Perhaps fearing to meet Magnus in battle after the internecine strife, according to the sagas Edgar—mistakenly called Malcolm—told Magnus he would renounce all Scottish claims to islands west of Scotland in exchange for peace. Magnus accepted the offer, which reportedly gave him every island a ship could reach with its rudder set. He gained recognition of his rule in the Southern Isles, including Kintyre after demonstrating that it should be included by sitting at the rudder of his ship as it was dragged across the narrow isthmus at Tarbert. Historian Richard Oram has claimed that references to a formal agreement with the Scottish king is a "post-Norwegian civil war confection" designed to legitimise the agenda of Haakon IV Haakonsson. Rosemary Power agrees with the Norse sources that a formal agreement with the Scots was probably concluded, and Seán Duffy notes that Edgar "happily ceded" the isles to Magnus since he had "little or no authority there in any case". Magnus spent the winter in the Hebrides (continuing to fortify the islands), while many of his men returned to Norway. There may have been talks at this time of Magnus marrying Matilda, daughter of late Scottish king Malcolm III Canmore, but no marriage took place. Magnus returned to Norway a year later during the summer of 1099, although many of the islands he had conquered (such as Anglesey) were only nominally under Norwegian control.