Elected Vice President in 1796, when he came in second to John Adams of the Federalists , Jefferson opposed Adams and with Madison secretly wrote the Kentucky and Virginia Resolutions , which attempted to nullify the Alien and Sedition Acts .