The Zurich cantonal parliament only narrowly rejected voting rights for foreigners.
The move was being pushed by the left-wing parties. It would have allowed communes in the canton to make their own decision on whether to give non-Swiss the right to vote on local issues.
It was rejected by 84 votes, to 82 in favour. Two abstained.
Eight cantons, including Vaud and Geneva, allow foreigners to vote as well as hundreds of communes.