A surface treatment liquid, comprising a resin and a solvent, wherein the resin has a functional group I that is a nitrogen-containing heterocyclic group and a functional group II that is a functional group other than the functional group I and is one or more groups selected from hydrophilic groups and hydrophobic groups, and the resin comprises a constituent unit having the functional group I, and one or more constituent units selected from the group consisting of a constituent unit having a cationic group in a side chain and a constituent unit having an anionic group in a side chain, wherein, in the constituent unit having the functional group I, when the functional group I is in the side chain and the nitrogen-containing heterocyclic group as the functional group I is a functional group that can be made to be cationic, the resin may not need to have a constituent unit in addition to the constituent unit, and when an anionic group selected from a phenolic hydroxyl group or a carboxy group is included in the constituent unit that has the functional group I, the resin need not include the constituent unit in addition to the constituent unit, wherein the hydrophilic group is an anionic group or a cationic group, wherein the cationic group is selected from a functional group consisting of a cation and a counter anion, and a functional group that can be made to be cationic, and the anionic group is selected from a functional group consisting of an anion and counter cation, and a functional group that can be made to be anionic, and wherein the compound giving a nitrogen-containing heterocyclic group is at least one compound selected from the group consisting of pyrrole, oxazole, isoxazole, oxadiazole, thiazole, isothiazole, thiadiazole, imidazole, triazole, pyrazine, pyrimidine, pyridazine, triazine, tetrazine, pentazine, indole, isoindole, indolizine, benzimidazole, benzoxazole, benzothiazole, carbazole, purine, quinoline, isoquinoline, quinazoline, phthalazine, cinnoline, and quinoxaline, and wherein the hydrophobic group is one or more groups selected from the group consisting of a silyl group, and a siloxane group. wherein the resin has a functional group I that is a nitrogen-containing heterocyclic group and a functional group II that is a functional group other than the functional group I and is one or more groups selected from hydrophilic groups and hydrophobic groups, and the resin comprises a constituent unit having the functional group I, and one or more constituent units selected from the group consisting of a constituent unit having a cationic group in a side chain and a constituent unit having an anionic group in a side chain, wherein, in the constituent unit having the functional group I, when the functional group I is in the side chain and the nitrogen-containing heterocyclic group as the functional group I is a functional group that can be made to be cationic, the resin may not need to have a constituent unit in addition to the constituent unit, and when an anionic group selected from a phenolic hydroxyl group or a carboxy group is included in the constituent unit that has the functional group I, the resin need not include the constituent unit in addition to the constituent unit, wherein the hydrophilic group is an anionic group or a cationic group, wherein the cationic group is selected from a functional group consisting of a cation and a counter anion, and a functional group that can be made to be cationic, and the anionic group is selected from a functional group consisting of an anion and counter cation, and a functional group that can be made to be anionic, and wherein the compound giving a nitrogen-containing heterocyclic group is at least one compound selected from the group consisting of pyrrole, oxazole, isoxazole, oxadiazole, thiazole, isothiazole, thiadiazole, imidazole, triazole, pyrazine, pyrimidine, pyridazine, triazine, tetrazine, pentazine, indole, isoindole, indolizine, benzimidazole, benzoxazole, benzothiazole, carbazole, purine, quinoline, isoquinoline, quinazoline, phthalazine, cinnoline, and quinoxaline, and wherein the hydrophobic group is one or more groups selected from the group consisting of a silyl group, and a siloxane group.