The compressive and tribological behavior of chemically crosslinked, surface-attached hydrogel layers has been investigated by indentation and friction tests using an atomic force microscope provided with a colloidal probe, where the probe is covered with a chemically identical hydrogel layer. The hydrogel layers are composed of a polydimethyl acrylamide copoly mer containing methacryloyl benzophenone units which is photochemically crosslinked and bound to substrates carrying self-assembled monolayers of a benzophenone group containing silane. The compression and friction behavior of the thus generated surface-attached hydrogel samples, which due to the surface attachment can only swell in one dimension, are studied as a function of film thickness and crosslink density. It is found that the pressure-induced deswelling in the contact region dominates the friction between two surfaces coated with surface-attached hydrogels and that the rate of loading and the film thickness determine the tribological properties, especially when the layer thicknesses are lower than 1 mu m.