A substance that stimulates an immune response.