Lord Justice Gross, who sits in the Court of Appeal, made the comments in a speech to the Institute of Maritime Law on Wednesday.
He said: "No one goes into the Judiciary to make money. But there comes a point when pay is so far out of line with the private sector market that it endangers recruitment – of the very best – and retention. There is a danger in relying unduly on goodwill.
"More than the money, there is the perception that these issues reflect government not valuing the Judiciary – and even Judges do take note, as recent surveys of judicial morale have so clearly shown."
He added that recent changes to the judicial pension scheme, which forced younger judges to join a less generous career-average scheme instead of the older final salary pension scheme, had "significantly aggravated" the problem.
"If we do not address pay and pensions, over time the quality of our judiciary will decline," he added.
The speech focused on the importance of maintaining the high quality of the British legal system so businesses and individuals continue to come to London courts after Brexit.
The judiciary has been facing a recruitment crisis, with the Lord Chief Justice warning in his annual report, published in September, that there are "significant difficulties" recruiting judges to senior levels.
"Any failure to address the problems of pay and pensions will have a serious impact on morale and on recruitment," the report said.
On Thursday a report from the House of Lords constitution committee said it was "seriously concerned" about the problem of recruiting judges, in particular to the High Court.
Applications for 25 High Court vacancies also opened on Thursday and as part of its recruitment drive the Judiciary published a series of videos showing current High Court judges talking about their work.
Judicial pay is currently undergoing a review by the Senior Salaries Review Body, a Government adviser, which is due to finish in June next year.
The House of Lords report also noted the "growing disparity" between public and private-sector jobs but added that due to public sector pay restrictions it was "unlikely judicial pay will increase in a way that significantly reduces this difference".
The most recent figures issued by the Ministry of Justice show that judges are paid salaries on a scale between £85,954 and £252,079, the salary of the Lord Chief Justice, the head of the judiciary in England and Wales.
As a Lord Justice of Appeal, Lord Justice Gross is paid a salary of £206,742, which has risen from £202,668 in 2015. He has been sitting in the Court of Appeal since 2010.
High Court judges are paid £181,566, while Old Bailey judges are paid £145,614.
A MoJ spokesman said: “Our independent judiciary is the cornerstone of the rule of law, and effective remuneration is critical to the continued attraction and retention of high calibre judges.
“The Senior Salaries Review Body is conducting a major review of judicial pay which is due to report next year, and we will continue to work closely with the judiciary on these issues.”