“THIS has been an absolute earthquake and a disaster for Serco,” Rupert Soames, the boss of Britain’s biggest provider of outsourced government services, told Parliament in September. He was referring to a 2013 scandal in which his firm, along with its peer G4S, continued to charge for electronic tagging of prisoners even after some had died. But it turned out that Serco’s misfortune was just beginning. On November 10th it wrote off £1.5 billion ($2.4 billion) relating to losses on contracts and acquisitions, cut its profit forecast, cancelled its dividend and announced plans both to sell some assets at a loss and to raise £550m through a share issue. Its share price fell by a third.

Serco’s travails are largely self-inflicted and unusually grave. But its “cautionary tale”, as Mr Soames puts it, should give pause to any company thinking of entering a growing market for the hard end of outsourced government services: not cleaning, catering or maintaining computers, but such things as guarding prisoners and dealing with welfare claimants.

Britain has long been a pioneer in outsourcing public services. But Australia has overtaken it in the proportion of inmates held in private prisons (see chart). The world’s second-biggest private prison is in South Africa; and Japan and Brazil have begun similar experiments. Two of France’s big outsourcing firms, Sodexo and Atos, take on tougher tasks in Britain than they do at home. Last month Sodexo, which runs five British prisons, was chosen as one of the preferred bidders for the privatisation of some probation services. Atos operates a scheme to assess disability-benefits claimants, though it has announced that it will give up the contract next year.

Firms that have taken on such work have come under constant fire from the public, press and politicians. Last year Australia’s Human Rights Commission expressed “grave concern” over housing and health care at a Serco-run detention centre for asylum-seekers, and this year G4S ended its contract at an Australian detention centre based in Papua New Guinea after a riot in February in which one person died. In Britain, an official auditor is investigating claims that Serco failed to conduct the required mental-health assessments at a centre for women awaiting deportation, where the firm had previously fired workers for improper sexual relationships with detainees. Another British contractor, Capita, took so long to evaluate eligibility for disability benefits that some claimants died before their requests were processed. Atos decided to end its disability-benefits contract after 40% of the appeals against its decisions were upheld, and its staff received hundreds of death threats. This week G4S said it had sold a business which has contracts at Guantánamo Bay, reportedly because the American government would not let it, as a foreign firm, exercise control over the division. Of course, private operators may be no more prone to mishaps than governments when they provide such services directly. But the reputational damage can harm a contractor’s prospects in other businesses. After the tagging scandal, Britain’s government gave G4S and Serco no new contracts for six months. G4S has begun to recover, but Serco is still reeling. In August it said it had lost eight of the ten “major opportunities” for business it had bid on this year. It also lost a £125m-a-year contract to run London’s Docklands Light Railway, which it had held since 1997. Demand for its services from private firms has also fallen. Australia is now seeking to turn back asylum-seekers at sea, so with fewer detainees to house, revenues from Serco’s biggest contract have dwindled. None of this means outsourcing is always bad business. Serco has prioritised growth over profits—it loses money on every asylum-seeker it houses in Britain. But Capita has been more cautious. The firm often declines to bid for contracts with big upfront costs or risks it cannot control, even if they appear profitable. Such prudence has not shielded the company from brickbats—critics have dubbed it “Crapita”. But since 2002 its profits have quadrupled.

Another successful approach comes from across the Atlantic. The two big private-prison firms in the United States, Corrections Corporation of America and GEO Group, have delighted shareholders with an average annualised return since 2004 of 18.5%. The main cause is America’s bloated justice system, which locks up more people than in other rich countries. Both companies have been criticised for funding groups that lobby for harsh sentencing. But they have also benefited from an impregnable competitive position. They have no other businesses with reputations to put at risk. And since they build their own prisons, it is hard for governments to dismiss them, because there would be nowhere else to put their inmates.

Serco’s Mr Soames says he will learn from his rivals: he wants to become “better at saying no”. And he plans to get out of the softer business-to-business contracts whose prospects were damaged by controversies in Serco’s penal services. Firms that do tough stuff like depriving people of their liberty and denying them welfare benefits can never expect to be loved, except perhaps by their shareholders.