He studied at the University of Glasgow, graduated there in 1628, and in 1634 was ordained as minister of Cambusnethan by Archbishop Patrick Lindsay. He was deposed by the synod of Glasgow in April 1639 for signing the protestation of the bishops and their adherents against the assembly of 1638, but on professing penitence was restored by the assembly of 1639. The committee, to whom his case was referred, reported that "he was a young man of good behaviour, and well beloved of his parish, and guilty of nothing directly but the subscribing of the declinature". Thereafter he went with the times. In 1648 he supported the "Engagement", and was urged by his kinsman the Duke of Hamilton to accept a chaplaincy in the army raised for the rescue of the king. At the Restoration he was rewarded by a grant of money and the bishopric of Galloway, and along with Sharp, Leighton, and Fairfoul was consecrated at Westminster on 15 December 1661. Galloway was a stronghold of the extreme covenanters. Many of the ministers refused to submit to episcopacy, and when deprived held field meetings, which were largely attended by their old flocks. At the request of the bishop and his clergy, whose ranks had been recruited from the north, soldiers were quartered on the frequenters of conventicles to compel their attendance at church, and there appears to be good authority for the statement that Sir James Turner, the officer in command, "was obliged to go beyond his instructions to satisfy the bishop". Hamilton acquired the estate of Broomhill in 1669 from his brother, who had been raised to the peerage, and died in August 1674. Burnet describes him as "a good-natured man, but weak". Wodrow says: "His gifts were reckoned every way ordinary, but he was remarkable for his cunning and time-serving temper"; while one of his grandsons describes him as "mighty well seen in divinity, accurate in the fathers and church history … very pious and charitable, strict in his morals … and every way worthy of the sacred character he bore". In 1635 he married Margaret, only daughter of Alexander Thomson, minister of Edinburgh, and had four daughters and two sons, one of whom, James, an advocate died in 1674.