As well as health boards and emergency services, the rules will also apply to colleges and universities.

Equalities Secretary Angela Constance said the aim was to "shatter the glass ceiling" encountered by women.

“Women’s voices need to be heard, and they need to shape the decisions made in our boardrooms," she said.

"Scotland’s public bodies, colleges and universities are responsible for significant expenditure and oversee services spanning all aspects of people’s lives.

“It’s really important we continue to encourage women to apply for these positions – and we are seeing good progress. Over the last decade the numbers of women on public boards has risen from 35% to 45%, and last year saw more women than men appointed. But this progress doesn’t just happen by accident. It has been achieved through the shared ambition and action of all of those involved and this bill will ensure that progress doesn’t slip back."

Scottish Labour's equality spokesperson Monica Lennon said: "Creating legislation that gives women greater rights to representation is a bold move, and I hope that it is the first step towards creating an equal playing field for all women at all levels of public life."

Scottish Conservative Alison Harris spoke on behalf of Annie Wells, who had lost her voice. "Positive action does not have to mean putting through legislation for legislation’s sake," she said. "We need to promote educational reform and make improvements in childcare and society’s attitude more generally if we are to make a real difference for girls growing up in Scotland today."