Electronic passport books contain a contactless smart card chip that makes it virtually impossible to counterfeit. First, when the passport is personalized for an individual, the information inside the chip is "signed" using a type of electronic seal. That "seal," called a digital signature, can be checked using a reader at passport control to prove that the passport was issued by a legitimate government authority. No one else can duplicate this seal, so no one can make a counterfeit epassport.
In addition, the information on the front page of the passport is stored electronically in the chip, including the photograph. If the chip data does not match the printed page information, the border agent knows something is wrong. Any attempt to change the passport information in the chip breaks the digital seal, so tampering with the chip data is also evident to a border agent.
See also, the Biometric passport tutorial.