The baseline rule, as stated by the Shulchan Arukh (Yoreh De'ah 197:2), is that when a woman's husband is in the city it is a mitzvah for her to immerse at the proper time without delaying even a single night, so as not to nullify the obligation of procreation.
Building on this, the Rema's gloss recorded in the Shulchan Arukh (Yoreh De'ah 197:2) and elaborated by the Arukh HaShulchan (Yoreh De'ah 197) permits immersion on Shabbat night when it was impossible to immerse beforehand — but only if the husband is present; otherwise immersion on Shabbat night is forbidden.
A key qualification governs cases where immersion could have taken place earlier: if it was possible to immerse before Shabbat — for example, because the husband was away and arrived on erev Shabbat — some authorities rule she may not immerse on Shabbat night, and some communities adopted this stringency, as recorded in the Shulchan Arukh (Yoreh De'ah 197:2) and the Arukh HaShulchan (Yoreh De'ah 197).
An earlier source, the Gemara in Niddah 67b, reflects the underlying tension: Rav Huna cited the practice of washing on erev Shabbat and immersing only at the conclusion of Shabbat as a precedent permitting a gap between washing and immersion, while Rav Hisda rejected that proof, noting that Shabbat circumstances — where immersion is impossible on Shabbat itself — are a forced exception and cannot serve as a model for ordinary weekday scheduling.
Even in cases of competing stringencies, the Shenei Luchot HaBerit (Hilchot Biah 2:17) ruled that when the husband is in the city the immersion carries the weight of a mitzvah, which was sufficient grounds to permit immersion on a Shabbat that coincided with a fast day — because the mitzvah dimension distinguishes the case.