TAIPEI, Taiwan — Demonstrators who have occupied Taiwan’s legislature since last week expanded their protest of a trade deal with China on Sunday evening by invading the government building nearby that houses the offices of the prime minister.

The protesters, including many students from local universities, have accused President Ma Ying-jeou and his allies in the governing Kuomintang of forcing through the trade measure without allowing a review of its details, which they fear will give Beijing too much influence over the island’s economy.

“I’m very angry at President Ma,” said Shiu Rung-kai, 21, a student at National Hsinchu University of Education who joined thousands of protesters inside the government compound.

By early Monday morning the police had cleared demonstrators from the government building, detaining dozens, according to local news media reports, although hundreds of protesters remained in the courtyard outside.