Liverpool had to fend off Chelsea to seal a deal for the future.