LONDON — In a national reckoning with its past, the Norwegian government has offered an official apology to women — and their offspring — who were ostracized, stigmatized and in some cases deported because of their relationships with German soldiers during World War II.

The apology came from Prime Minister Erna Solberg, who lamented that the women had been treated in an undignified manner for having relations or bearing children with German soldiers — or were just suspected of having done so. They were seen as traitors by Norwegian society. Many faced unlawful arrest by the authorities.

“Norwegian authorities violated the fundamental principle that no citizen can be punished without trial or sentenced without law,” Ms. Solberg said at an event on Tuesday to commemorate the 70th anniversary of the Universal Declaration of Human Rights.

Most of the women — known as the “German girls” — did not hear the apology because most have long since died. The prime minister conceded, however, that the apology was long overdue.