NASHVILLE — Chickens, long forbidden in Nashville’s urban precincts, will now get to cluck in the city — legally.

After a 45-minute debate and a close decision to let nearly one-quarter of Davidson County opt out, the Metro Council voted 21-15 on Tuesday to allow residents to raise hens in their back yards.

The legislation, which awaits Mayor Karl Dean’s signature, will allow people living in residential zoning districts to keep up to two, four or six chickens, depending on the size of their property, for an annual permit fee of $25. Chickens won’t be allowed in front yards, and roosters will be prohibited.