An optical filter having a near-infrared-absorbing layer which contains an ingredient comprising a phosphoric ester compound represented by formula (10) and copper ions and in which the amount of phosphorus atoms is 0.4 to 1.3 mol per mol of the copper ions and the content of copper ions is 2 to 60 wt.%. By regulating the contents of phosphorus atoms and copper ions so as to be within the respective given ranges, the filter not only has the sufficient ability to absorb near infrared but has such improved moisture resistance that loss of transparency caused by blushing is inhibited.