The Taiwanese government is set to pass a bill legalizing gay marriage which is being opposed by many residents of the capital city Taipei, according to media reports.

Thousands of demonstrators protested against the bill in front of the Legislative Yuan last week.

They held signs with messages that urged the government to let the people determine the legitimacy of the institution of marriage and family.

The China Post reported that protesters had put large stickers on their clothes which read "Marriage and family, let the people decide."

Many young children were seen standing in the rally with their parents who had gathered there since early morning.

In the afternoon, about 60 demonstrators forced their way into the gate of the Legislative Yuan complex and sat outside the assembly hall in protest after the lawmakers declined to allow a public hearing to discuss the matter. Later they were removed from the complex and the gate was cordoned off.

The officials relented and will hold two public meetings before voting proceeds in the legislature.

The Alliance of Taiwan Religious Groups for Protection of Family had organized the rally. Many of the protest leaders spoke to the crowd from a temporary stage at the site. One of the leaders was heard as saying: "All children have the right to a mother and a father."

The group supported some of the rights such as emergency visitation and inheritance rights for same-sex partners, but said that marriage should be between a man and woman only.

"Now they want to amend the law to do away with the 'father' and 'mother' altogether," David Tseng, rally spokesperson told AFP. "We are different from the West. In Eastern culture, we place great importance on filial piety to one's father and mother. This is a virtue we must keep," he added.

The conservative Kuomintang (KMT) party had dominated the country's politics for years before Democratic Progressive Party came in power in May this year.

President Tsai Ing-wen backs gay marriage, and said she would stand by the outcome of voting in the legislature.

If this bill is passed, Taiwan would become the first Asian country to legalize same-sex marriage.

Gay pride rallies are an annual event in Taipei and the one in October was attended by tens of thousands of people.