Dalrymple was elected to represent
Culross in 1698 in the
Parliament of Scotland, as a member of the Stair–Queensberry alliance. He was created
baronet on 8 May 1701 and was also appointed joint solicitor-general for Scotland and auditor of treasury of Scotland in 1701. He was a Commissioner for the union with England in 1702, and again in 1706 when he was one of the Commissioners who negotiated the
Act of Union 1707. In 1707 Dalrymple was one of the
Scottish representatives to the first Parliament of Great Britain and at the
1708 British general election, he was returned as
Member of Parliament for
Haddington. In 1709 he was promoted from solicitor-general to the post of
Lord Advocate of Scotland .Also in 1709, he bought Broughton House, renaming it
Newhailes after the Dalrymple's Castle Hailes. He was returned again for Haddington at the
1710 British general election. In 1711 he lost the post of Lord Advocate under the Tory administration. In 1712, he was elected
Dean of the Faculty of Advocates which he held for the rest of his life. He was returned again at the
1713 British general election and regained his post as Lord Advocate in 1714. Dalrymple was returned as MP for Haddington at the
1715 British general election. He was Commissioner of visitation for
Glasgow University in 1717 and 1718, and for St Andrews University in 1718. He was appointed auditor general of the Scottish Exchequer in 1720. ==Personal life==