Thousands of children of legal immigrants will be closer to obtaining subsidized health insurance this summer after the Legislature passed a long-debated expansion of the state’s KidCare program.

Until this year, children of legal immigrants were technically eligible for KidCare — the low-cost federal-state health insurance program — but had to wait five years to actually start receiving services.