Kamehameha, reigning over the western part of the island, with its favorable anchorages at Kailua and Kealakekua Bay, gained a distinct advantage over his foes by acquiring not only the benefits of European ideas and military strategies, but also advanced technology such as arms and gunpowder. By 1790 he had managed to acquire guns, light cannon, and an armed schooner, in addition to the advice and technical expertise of two European seamen, John Young and Isaac Davis.
Setting aside for the moment his ambitions on his own island, however, Kamehameha decided to invade Maui, where he defeated its defending army but failed to capture the important chiefs. When Kamehameha pushed on toward Moloka'i, Keoua took advantage of his absence, and, defeating Keawemauhili, invaded his other rival's territory, laying waste Hamakua and Kohala. Quickly returning to defend his lands, Kamehameha secured them but did not defeat Keoua and decided to again invade Maui. It was during Keoua's retreat to his home district of Ka'u that part of his army, passing near the summit of Kilauea volcano, was suffocated during a rare explosive eruption - a signal to many observers that the gods favored Kamehameha. Although weakened psychologically as well as physically by this tragedy, Keoua remained tenacious and managed to hold his own against Kamehameha's forces for several more months.
Meanwhile, from Moloka'i, Kamehameha had sent his aunt to Kaua'i to consult a kahuna as to what the future course of his actions should be in order to take possession of Hawai'i and the rest of the islands. Instead, she found on O'ahu the famous prophet of Kaua'i-Kapoukahi. This man., who according to the historian John Papa I'i was skilled in selecting propitious sites for heiau, told Kamehameha that if he rebuilt the temple at Pu'ukohola ("hill of the whale") near Kawaihae and rededicated it to honor Ku-ka'ili-moku, he could conquer the rest of the islands. Kapoukahi supposedly prophesied that "War shall cease on Hawaii when one shall come and shall be laid above on the altar (lele) of Pu'u-kohola, the house of god." 
A few sources state that construction of this heiau had been an intention of Kamehameha for some time. Kamaka Paea Kealii Ai'a writes that "From time to time the High Priest of Kohala urged Tamaahmaah to build a heiau at Puukohola, Kawaihae, for which he would gain supremacy of Hawaii."  The Reverend Herbert Gowen states that Kamehameha had promised to build it [heiau of Pu'ukohola] years before this, but had evidently been trying carnal weapons first and leaving spiritual means as a kind of last resource." 
One part of the legend also states that Kamehameha first intended to refurbish and rededicate Mailekini temple, on the slope below Pu'ukohola. But Kapoukahi, who had joined Kamehameha's staff as royal architect, suggested that a new temple on the summit would be more appropriate and provide greater benefits.  According to Thomas Thrum, Kapoukahi instructed Kamehameha "to build a large heiau for his god at Puukohola, adjoining the old heiau of Mailekini. . . .  Thrum continues:
Of Mailekini heiau little of its history is learned, or what connection, if any, it had in its working with Puukohola within two hundred feet above it. In early days it was said that traces of an underground passage existed, though it was difficult to tell whether or not the two temples were connected by it. . . . A tradition is current that this was the one that Kamehameha set out to rebuild that he might be successful in war, but on the advice of Kapoukahi he transferred his labors to the upper one of Puukohola. . . . 
Only archeological excavations could provide definitive evidence on whether Pu'ukohola Heiau is a new structure or a renovation of an older, abandoned temple. According to Hawaiian mythology, the original temple of Pu'ukohola was consecrated by the god Lono about 1580.  Fornander gathered some data on this subject from native accounts:
A revolt occured on Hawaii which had its strength in Kohala during Lonoikamakahiki's visit to Kakuhihewa's court at Oahu, which hastened his return, and landing at Kealakekua where he began gathering his forces . . . they met and routed the rebels in two battles . . . . Reinforced from Kohala and Hamakua the rebels gave two other engagements, at Puupa and Puukohala [sic], near the heiau of that name, in both of which Lono was victorious, and Kanaloakapulehu, one of the four revolting brothers, was taken prisoner, slain, and sacrificed at the heiau. Puukohola is one of several named heiaus consecrated by Lono, as acknowledgment to the gods for his victories after he had restored peace and order. This indicates that the heiau of Puukohola was in existence in the time of Lonoikamakahiki (1565-95). . . . 
Fornander states that the long years of warfare and strife were becoming tiring to Kamehameha, who "stood no nearer to the supremacy of Hawaii than he did on the day of Mokuohai."  Because neither spears nor guns had succeeded in annihilating Keoua, Kamehameha decided to follow the seer's advice "and the construction of the Heiau on Puukohola was resumed with a vigour and zeal quickened, perhaps, by a consciousness of neglected duty." 
According to Samuel Kamakau, Kamehameha
summoned his counselors and younger brothers, chiefs of the family and chiefs of the guard, all the chiefs, lesser chiefs, and commoners of the whole district. Not one was allowed to be absent except the women. . . .The building of the heiau of Pu'u-kohola was, as in ancient times, directed by an expert . . . by a member of the class called hulihonua who knew the configuration of the earth (called kuhikuhi pu'uone) . . . .
When it came to the building of Pu'u-kohola no one, not even a tabu chief, was excused from the work of carrying stone. Kamehameha himself labored with the rest. The only exception was the high tabu chief Ke-ali'i-maika'i [Kamehameha's younger brother]. . . . Thus Kamehameha and the chiefs labored until the heiau was completed, with its fence of images (paehumu) and oracle tower (anu'unu'u), with all its walls outside and the hole for the bones of sacrifice. He brought down the ohi'a tree ('ohi'ako) for the haku 'ohi'a and erected the shelter house (hale malu) of'ohi'a wood for Ku-ka'ili-moku according to the rule laid down for the kahuna class of Pa'ao. 
According to Historian Kuykendall, basing his information on Kamakau and Fornander, in 1790
The building of this heiau was a great and arduous undertaking. Priests were everywhere about; they selected the site, determined the orientation, the dimensions, and the arrangement of the structure, and at every stage performed the ritualistic ceremonies without which the work could not be acceptable to the gods. 
Fornander states that an aged informant from Kawaihae had actually helped carry stones for the construction of Pu'ukohola Heiau. This man painted a vivid picture of thousands of people encamped on the hillsides and described the careful regulation of their eating periods, work shifts, and break times. He also mentioned the large number of chiefs present and the numerous human sacrifices required at various stages of construction. 
A revolt on the islands of Maui, Lana'i, and Moloka'i, followed by an invasion of North Kohala by the previously conquered chiefs of those islands, interrupted work on Pu'ukohola Heiau. Possibly the news that Kamehameha was building a major temple unsettled his rivals to such an extent that they hoped that even if they could not kill the ambitious chief, they could at least keep the temple from being ritually perfect by interfering with its erection and the attendant ceremonies. If the construction process displeased Ku-ka'ili-moku, Kamehameha's foes reasoned, it might eliminate or reduce the spiritual power exuded by the heiau.
A sea battle in 1791 near Waipi'o Valley raged, with both Kamehameha and his foes utilizing muskets and cannons operated by foreigners. Kamehameha's fleet included, in addition to double canoes armed with cannons, his warship Fair American. Young and Davis commanded his artillery. This battle of Kepuwaha'ula'ula, or "the red-mouthed gun," referring to the repeated firing of cannons and muskets as well as possibly to the carnage, resulted in defeat of the invading forces. Apple states that this was Hawai'i's "first and last real sea battle using Hawaiian canoes and Western gunpowder." 
Kamehameha then resumed construction of his heiau, a massive terraced and walled hilltop platform built of mortarless, waterworn lava rocks and boulders. Measuring about 224 by 100 feet, it contained walls on each end and the landward side. The side toward the sea remained open. Three narrow, terraced steps down the hillside to the west enabled the interior to be seen from the sea. The temple was finished in the summer of 1791.
It has been written that Keoua was enticed to the dedication of Pu'ukohola Heiau by a ruse, in the belief that he and Kamehameha were to arrange a treaty of peace. Given the past history of the two men, however, it is hard to believe that Keoua would have considered this a possibility. Keoua and his retinue proceeded to Kawaihae amidst considerable pomp and pageantry. According to legend, the journey had "the appearance of a fatalistic resignation to the doom which he clearly recognized as a possible issue of his journey to Kawaihae."  Samuel Kamakau relates that
He [Keoua] brought out all his weapons of war, his feather capes and feather helmets, and placed them in Keawe-a-heulu's canoes. He also ranged his chiefs about him in his own double canoe, those of high rank and those who had lived with him and upon whose love he could count and who would die with him. Such was the custom with chiefs of old to have many companions in death(moepu'u). Keoua knew that he was to die. . . 
Keoua placed the reminder of his companions in a canoe with his younger brother Kaoleioku.  Kamehameha, resplendent in feather cloak and helmet, stood on the shore below the heiau to greet his visitors. Versions differ as to what happened next, but at some point, while Keoua was disembarking, someone among Kamehameha's retainers killed him and the others in his canoe; Kamehameha did, however, prevent the killing of Kaoleioku and others in the party.  Fornander states that prior to Keoua's arrival, "the umu had been prepared and was red hot. Keoua was then roasted" before he and the other victims were offered up as sacrifices to celebrate this great victory. 
Many questions have been raised as to why Keoua willingly entered the camp of so bitter an enemy. Fornander believed that the defeat of Kamehameha's enemies in the battle of Kepuwaha'ula'ula probably influenced Keoua to try to negotiate with Kamehameha.  Perhaps Keoua realized the political and religious significance of this heiau and surmised that with its completion his fate was sealed. Whether his death occurred by or against Kamehameha's wishes is also disputed. After critically examining the statements of a variety of early native and foreign writers on the subject, Fornander concludes that
it is impossible to acquit Kamehameha of complicity in the cruel death of Keoua. It must have been planned in his council. It was executed by three of his highest chiefs and most trusted counsellors. The deed itself took place in his presence and within sound of his voice; and there is no mention, tradition, or hint that he ever disapproved or regretted it, or in the slightest manner rebuked or punished those who treacherously enticed Keoua away, or him who actually stabbed him. 
Whether planned or not, the assassination of Keoua gave Kamehameha undisputed control of Hawai'i Island by 1792. In early 1795 Kamehameha took Maui, Lana'i, and Moloka'i. With the conquest of O'ahu that year, Kamehameha's aggressive military policy succeeded in bringing all the islands but Kaua'i under his control. In 1810 that island's paramount chief acknowledged Kamehameha's supremacy, completing the consolidation of the islands into the Kingdom of Hawai'i, which Kamehameha ruled until 1819 and his descendants until 1872.  Although the monarchy was overthrown in favor of a republic in 1894, it established the foundation for the future state of Hawai'i.