With his wife Lady Jane Ogilvy, he was largely responsible for the foundation of
Baldovan Institute in 1852, Scotland's first residential hospital for learning disabled children. He was closely involved, along with Dr
James Arrott, the head physician, in the moving of
Dundee Royal Infirmary to a new site, and played a prominent part in the laying of the foundation stone for the new building on 22 July 1852. He also established the Dundee Corn Exchange in 1856. He made an unsuccessful attempt to represent
Montrose in
parliament when a
by-election was called there in 1855. He had better luck in the
general election two years later, when he was elected to represent
Dundee. Ogilvy was MP for Dundee from 1857 to 1874, originally as its sole member, but from 1868 was one of two members representing the town after it became a two-member constituency. He was first elected at
the general election of 1857, defeating his future colleague
George Armitstead, by 245 votes. In both
1859 and
1865 he was returned unopposed. In the first election for the new two member seat in
1868 he was elected in second place, finishing 77 votes behind Armitstead, but polling over 3,000 votes more than third placed candidate. ==Marriage and progeny==