Coalition government agrees annual levy on emissions from livestock after months of fraught negotiations