We present a study of large-scale bars in field and cluster environments out to redshifts of ∼0.8 using a final sample of 945 moderately inclined disk galaxies drawn from the EDisCS project. We characterize bars and their host galaxies and look for relations between the presence of a bar and the properties of the underlying disk. We investigate whether the fraction and properties of bars in clusters are different from their counterparts in the field. The properties of bars and disks are determined by ellipse fits to the surface brightness distribution of the galaxies using HST/ACS images in the F814W filter. The bar identification is based on quantitative criteria after highly inclined (>60 • ) systems have been excluded. The total optical bar fraction in the redshift range z = 0.4−0.8 (median z = 0.60), averaged over the entire sample, is 25% (20% for strong bars). For the cluster and field subsamples, we measure bar fractions of 24% and 29%, respectively. We find that bars in clusters are on average longer than in the field and preferentially found close to the cluster center, where the bar fraction is somewhat higher (∼31%) than at larger distances (∼18%). These findings however rely on a relatively small subsample and might be affected by small number statistics. In agreement with local studies, we find that disk-dominated galaxies have a higher optical bar fraction (∼45%) than bulge-dominated galaxies (∼15%). This result is based on Hubble types and effective radii and does not change with redshift. The latter finding implies that bar formation or dissolution is strongly connected to the emergence of the morphological structure of a disk and is typically accompanied by a transition in the Hubble type. The question whether internal or external factors are more important for bar formation and evolution cannot be answered definitely. On the one hand, the bar fraction and properties of cluster and field samples of disk galaxies are quite similar, indicating that internal processes are crucial for bar formation. On the other hand, we find evidence that cluster centers are favorable locations for bars, which suggests that the internal processes responsible for bar growth are supported by the typical interactions taking place in such environments.