Victorian crime drama Ripper Street is to return to screens via Amazon's video on demand service.
The BBC cancelled the show in December due to poor ratings, but Amazon has now commissioned a third season for its Prime Instant Video service - formerly known as Lovefilm Instant.
The show will premiere on Amazon and screen on the BBC a few months later.
Amazon has also acquired the UK subscription streaming rights of the first two series of the show.
The BBC will continue to make a contribution to production costs of the new season, while other broadcast partners - including BBC America and the Irish Film Board - will remain on board as part of the new arrangement.
Filming on the new series - which will continue to be produced by Tiger Aspect and Lookout Point - will begin in May.
A date for its premiere on Amazon Prime has yet to be determined.
The programme's makers said the third series would go ahead as originally planned with eight episodes, the same budget and "slightly more bells and whistles" than the previous two series.
The existing principal cast - including Matthew Macfayden and Jerome Flynn - will return to the show's purpose-built set in Dublin, with some filming in the UK for the first time.
Macfadyen, who plays Det Insp Edmund Reid in the drama, said he was "delighted" Ripper Street had been saved.
"We all thought that it had legs," he said. "We didn't feel like it was petering out."
The actor joked he was looking forward to wearing his bowler hat again - the defining feature of his character.
Executive producer Will Gould said the show's cancellation "shocked" him and it felt like "unfinished work".
"We had more to do, It feels right to be going back. There are stories left to tell," he added.
Series creator and writer Richard Warlow said the story would pick up four years after the drama's last outing in December, adding he would continue to work with creatives at the BBC on the project.
He said there was scope for more series of the drama, set in the sharp-edged streets of 19th Century east London.
"It feels that the potential of what I can do is broader than it was," added the writer, in reference to the new deal with Amazon.
Ben Stephenson, the BBC's controller of drama commissioning, said: "This is an exceptional opportunity to bring back Ripper Street for a third series by working with the right partners.
"This deal gives fans another series of the show they love at excellent value to the licence fee payer."
Similar deals of its kind are not expected to follow.
However, Amazon's Tim Leslie said if audiences loved a cancelled show and wanted to bring it back, they would consider it.
The first series of Ripper Street, set in Whitechapel following the notorious killings of Jack the Ripper, attracted nearly eight million viewers when it launched in 2012.
However the second series averaged 4.8 million viewers across the eight episodes, struggling to compete against ITV's I'm A Celebrity... Get Me Out of Here! which attracted a series average of 11.1 million viewers.
The cancellation triggered a social media campaign to have the drama reinstated.
Responding to the show's reprieve, the Save Ripper Street team tweeted: "We #SaveRipperStreet fans may have been little more than a flea in the ear of BBC One in the greater scheme of things. But what a flea!"
Actress MyAnna Buring, who plays Long Susan, said fan reaction was "incredibly moving" in response to the BBC's decision not to recommission the show.
"I don't think without that kind of response everyone would have been inspired to create a deal like this," she added.