The Sri Harmandir Sahib was invaded and destroyed many a times by the Afghan and other invaders. Each and every time the Sikhs had to sacrifice their lives in order to liberate it and restore its sanctity. After the martyrdom of Bhai Mani Singh ji in 1737, Massa Ranghar, the Kotwal of Amritsar took charge of Sri Harmandir Sahib in 1740 and converted it into a civil court and began to hold notch parties. This act created great resentment among the Sikhs. Two warriors, Sukha Singh and Mahtab Singh avenged the insult by a dare devil act. They entered the temple complex in guise of peasants, severed the head of Massa Ranghar with a single blow of kirpan and fled away with decapitated head on one of the their spears. After this incident the security around the Sri Harmandir Sahib was further tightened and the temple was locked.
Now, it was the turn of Lakhpat Rai, a Hindu Diwan of Lahore Darbar as he vowed to finish the entire Sikh Nation. In order to avenge the death of his brother Jaspat Rai, he befouled the Sarovar and desecrated Sri Harmandir Sahib in 1746. He even banned the name 'Guru'. The Mughal forces marched against the Sikhs under the command of Diwan Lakhpat Rai and Yahiya Khan. A fierce battle was fought( the first Ghalughara in june 1746) in which nearly seven thousand Sikhs were martyred. Three thousand of them were put to death publicly at Lahore, (the site is now called Shaheedganj).
After this hollowcast, the Sikhs under the efficient leadership of Sardar Jassa Singh Ahluwalia retaliated back and recaptured both the city and Sri Harmandir Sahib killing Salabat Khan in March, 1748. They celebrated Vaiskhi with great enthusiasm by clearing the holy Sarovar and restoring the daily Maryada at Sri Harmandir Sahib. They also held 'Sarbat Khalsa'. The Dewali festival of 1748 was also celebrated enthusiastically.
In 1757, Ahmad Shah Abdali invaded India for the second time and attacked Amritsar. He demolished Sri Harmandir Sahib and filled the Sarovar (tank) with garbage. On hearing of the desecration, Baba deep Singh ji Saheed, the head of 'Misl Shaheedan', started at once to avenge the insult. A bloody encounter took place at the village Gohalwar near Amritsar. Baba Deep Singh was mortally wounded. He gripped and supported his severed head with his left hand and with the right, he went on mowing down the enemies. Thus fighting, this unique warrior reached the holy precincts and laid down his life for the cause of maintaining sanctity of Sri Harmandir Sahib.
On 10th April, 1762, Ahmed Shah Abdali again invaded Amritsar and Sri Harmandir Sahib, after the horrible carnage of the Sikhs at Kup Harira. On this occasion thousands of armed and unarmed Sikhs had gathered at the temple for a holy bath. Countless Sikhs laid down their lives in defense of their beloved shrine. Sri Harmandir Sahib was again blown up with gun powder and the holy tank was also desecrated. It is said that while the building of the shrine was being blown up, a flying brick bat struck the Shah on the nose. This wound proved fatal for him.
In December, 1764, Sri Harmandir Sahib was again attacked by Ahmed Shah Abdali with the sole object of destroying the entire Sikh Nation. But before his arrival the Sikhs abandoned the city and to his surprise he found only thirty Sikhs in the vicinity of Sri Harmandir Sahib, who under the command of Baba Gurbax Singh ji gave him stiff resistance and all were martyred. Abdali, again pulled down the newly constructed structure of the Shrine and leveled the holy tank.
Before the final departure from India in 1767, Ahmed Shah Abdali again attacked Amrtisar but he dared not enter Sri Harmandir Sahib, and it remained under the control of the Sikhs ever afterwards. (In June, 1984 it was attacked by the Indian Army, under operation Blue Star in which several hundred innocent Sikh pilgrims were killed).
After the Martydom of Bhai Mani Singh ji Sri Harmandir Sahib was collectively managed by the Sikh misls and many Bungas( Mansions) were constructed. Whenever the Sikh leaders visit Amritsar, they did not interfere in the affairs of the temple. All the general gatherings were held on Akal Takhat Sahib only in the presence of Guru Granth Sahib. During the rule of Maharaja Ranjit Singh the administration of Sri Harmandir Sahib went under the control of the State. Maharaja took keen interest in the development and beautification of Sri Harmandir Sahib.
During the British period, Sri Harmandir Sahib passed under the control of one man the 'Sarbrah' (Manager), a nominee of Deputy Commissioner of Amritsar. The Deputy commissioner of Amritsar also made a committee of so-called sikh Sardars and Raises. The Pujaries, Mahants, Ragis and other functionaries began to receive their customary share of offerings at the Temple. On the other hand immoral acts were practiced by them within the precincts of the temple with the connivance of Sarbrah. Great resentment prevailed among the Sikhs and outcome of this was Sikh Gurdwara Reform Movement. Now again the Sikhs had to sacrifice their lives for the cause of Sri Harmandir Sahib and other Shrines. The Shiromani Akali Dal became the spear head of the struggle for the reform of the places of worship.
The curtain was finally rung down upon the Gurdwara Reform Movement, when the Sikh Gurdwara Act, 1925, vested the control and management of Sri Harmandir Sahib in the Shiromani Gurdwara Parbandhak Committee, a representative body of the Sikhs elected by adult franchise.