He was the second illegitimate son of John Montagu by Martha Ray; he was acknowledged by his father, and brought up at Hinchingbrooke, Huntingdonshire. He was educated at Charterhouse School and Christ's College, Cambridge, where he matriculated in 1786, graduated B.A. (fifth wrangler) in 1790, and proceeded to obtain an M.A. in 1793. On 30 January 1789 he was admitted as a member of Gray's Inn, but continued to reside at Cambridge until 1795, when, having by a technical loophole lost the portion of inheritance intended for him by his father, he came to London to read for the bar.