Born in Irvine, North Ayrshire, in 1624, James was entered at Glasgow University on 31 March 1645, and was laureated in 1647. He was ordained to the ministry of Kirkintilloch on 19 February 1653, but was charged by the English rulers "not to preach in that church, and the people not to hear him". The parishioners adhered to him nevertheless. In 1655 he was transferred to Linlithgow. There he met with further obstruction, but the synod declared him to be lawfully called and admitted. He joined the party of the resolutioners, and on 29 May 1661 celebrated the restoration of Charles II by publicly burning the Solemn League and Covenant and the acts of parliament passed during the civil wars. In 1664 he was appointed parson of Hamilton, South Lanarkshire, to which office was annexed the deanery of Glasgow, and from 1665 to 1667 was rector of Glasgow University. On 6 January 1666, in that capacity, he headed the list of subscribers to the oath of allegiance to episcopacy. He used his influence to protect the Duke of Hamilton from injury at the skirmish of Pentland on 28 November 1666. In 1669 he and Arthur Rose, parson of Glasgow, drew up an address to the king protesting against the recent indulgence granted to presbyterian ministers. The council summoned Ramsay and Rose before it, declared the address to be illegal, and ordered it to be suppressed.
Bishop of Dunblane
Ramsay was on friendly terms with Gilbert Burnet and Bishop Leighton, with whose desire for a scheme of comprehension he sympathised. When Leighton was transferred in 1673 to the archiepiscopal see of Glasgow, Ramsay succeeded him as bishop of Dunblane. He held his first synod there on 30 September the same year. In the second year of his episcopacy he came into conflict with James Sharp, archbishop of St Andrews, whose arbitrary handling of the church had excited widespread discontent. The bishops of Brechin, Edinburgh, and Dunblane formulated a demand for a national synod. When, however, in July 1674, Sharp called a meeting of the bishops in his own house to consider certain canons for the church, Ramsay alone ventured to insist on the need of "a national convocation of the clergy". He was not summoned to the second day's conference, and returned to his diocese, leaving behind a letter denouncing the proposed canons as inopportune, and not within the province of a private consultative meeting of the bishops. The king, on 16 July 1674, in reply to the address of Ramsay and his friends, expressed "displeasure against all factious and divisive ways", and ordered Sharp to translate Ramsay to the see of the Isles. Ramsay, on receiving notice of the king's decision, petitioned the council to present his case again to the king, and, despite Sharp's opposition, the petition was forwarded to Lauderdale. An angry correspondence between Sharp and Ramsay followed. Sharp inhibited Ramsay, and proceeded to London. Thither, in April 1675, Ramsay followed him. The quarrel was submitted to the consideration of several English bishops of both provinces in September 1675, with the result that Ramsay retained the see of Dunblane. During 1676 and 1677 Ramsay was engaged in a suit against Francis Kinloch of Gilmerton for an annuity due to him as dean of the chapel royal, annexed to his bishopric. The case is of importance in the history of Scottish ecclesiastical revenues.
Bishop of Ross
In May 1684 he was transferred to the see of Ross. In 1686 he preached in the High Church, Edinburgh, before the members of parliament a sermon against the act for the toleration of Roman catholicism. As a consequence he was called before the archbishop of St Andrews and the bishop of Edinburgh to answer a charge of defaming the archbishop and his brother Melfort. "This staging of the bishop of Ross was one of the various methods employed to get the act for toleration of Popery to pass". On 3 November 1688, however, Ramsay signed the letter of the Scottish bishops to James, congratulating him on the birth of a son, and expressing amazement at the news of an invasion from Holland. On the abolition of episcopacy Ramsay was expelled from office, and died at Edinburgh, in great poverty, on 22 October 1696. He was interred in the Canongate churchyard. He married Mary Gartstair, and had eight sons and three daughters. His eldest son, Robert, was minister of Prestonpans.