Melville continued in the Principalship of St. Mary's for upwards of a quarter of a century--from the close of 1580 to 1606, when he was summoned by the King to London, never to return to his native land.
In St. Andrews and Glasgow he had not only teaching duties, he presided over the government of the University as well; and the same resolute respect for law, which set him so stoutly against the King's tyranny in the realm, made him a determined upholder of order in the University. He was at once a fearless subject and a born ruler of men. When he entered on his office in St. Andrews, some of the professors, chafed by the reforms which he introduced, became insubordinate, but soon succumbed to his authority; and more than once in Glasgow he quelled riots among the students at the risk of his life. On one occasion, when his friends urged him to condone an offence of a student of noble family from fear of revenge, he answered, 'Giff they wald haiff forgiffness let them crave it humblie and they sall haiff it; but or that preparative pass, that we dar nocht correct our scholars for fear of bangstars and clanned gentlemen, they sall haiff all the blud of my body first.'
In St. Andrews he was for some time Rector of the University as well as Principal of St. Mary's, and in his exercise of civil authority in that capacity he did more for public order than all the magistrates of the burgh. At one time the inhabitants were greatly plagued by a bad neighbour, the Laird of Dairsie, who had once been Provost, and who resented his ejection from that office. On more than one occasion associates of his, Balfour of Burley and others, had entered the city during the night and committed gross outrages. One day the report reached St. Andrews that Dairsie and his friends were approaching in force to make an assault on the citizens. The magistrates were panic-stricken; but on the report reaching the Rector's ears, he immediately summoned the whole University together and organised a party of resistance, placed himself at its head, bearing in his hand a white spear (one of the insignia of his office), and by his prompt action made the invaders glad to decamp.
During Melville's rectorship quarrels sometimes occurred between town and gown, and in these he always showed himself jealous in regard to the rights of the University. He had once a serious rupture with the magistrates, on account of their unjust administration and their rejection of eminent ministers whom he had commended for charges in the city. Preaching in his own pulpit in the College of St. Mary's, he spoke with such vehemence of their misdoings that he raised the town against him. Forthwith placards were affixed to the College gates threatening the Rector with dire revenge. Nothing daunted, Melville continued to fulminate against the authorities--'with ane heroicall spreit, the mair they stirit and bostit the mair he strak with that twa-eagit sword, sa that a day he movit the Provest, with sear rubbing of the ga of his conscience, to ryse out of his seatt in the middes of the sermont, and with some muttering of words to goe to the dure, out-throw the middes of the peiple.' Melville, instead of giving way to the irate magistrate, had him brought before the Presbytery, when he expressed his regret for disturbing the public worship, and craved forgiveness; and so peace was restored.