Zebrafish and goldfish are both diurnal freshwater fish species belonging to the same family, Cyprinidae, but their visual ecological surroundings considerably differ. Zebrafish are surface swimmers in conditions of broad and shortwave-dominated background spectra and goldfish are generalized swimmers whose light environment extends to a depth of elevated short wavelength absorbance with turbidity. The peak absorption spectrum (lambdamax) of the zebrafish blue (SWS2) visual pigment is consistently shifted to short wavelength (416 nm) compared with that of the goldfish SWS2 (443 nm). Among the amino acid differences between the two pigments, only one (alanine in zebrafish and serine in goldfish at residue 94) was previously known to cause a difference in absorption spectrum (14-nm lambdamax shift in newt SWS2). In this study, we reconstructed the ancestral SWS2 pigment of the two species by applying likelihood-based Bayesian statistics and performing site-directed mutagenesis. The reconstituted ancestral photopigment had a lambdamax of 430 nm, indicating that zebrafish and goldfish achieved short wavelength (-14 nm) and long wavelength (+13 nm) spectral shifts, respectively, from the ancestor. Unexpectedly, the S94A mutation resulted in only a -3-nm spectral shift when introduced into the goldfish SWS2 pigment. Nearly half of the long wavelength shift toward the goldfish pigment was achieved instead by T116L (6 nm). The S295C mutation toward zebrafish SWS2 contributed to creating a ridge of absorbance around 400 nm and broadening its spectral sensitivity in the short wavelength direction. These results indicate that the evolutionary engineering approach is very effective in deciphering the process of functional divergence of visual pigments.