An entanglement-generating protocol is described for two qubits coupled to a cavity field in the bad-cavity limit. By measuring the amplitude of a field transmitted through the cavity, an entangled spin-singlet state can be established probabilistically. Both fundamental limitations and practical measurement schemes are discussed, and the influence of dissipative processes and inhomogeneities in the qubits are analyzed. The measurement-based protocol provides criteria for selecting states with an infidelity scaling linearly with the qubit-decoherence rate.