Senior government figures have been left reeling after a shock vote harpooned their signature laws, aimed at cracking down on unions.