Nationalism in the Spanish colonies helped to lead to their independence because it inspired many people in the colonies to feel that they were being mistreated by the Spanish.
The people who led most of the rebellions against the Spanish were themselves ethnically Spanish. They were typically what were called “criollos” or “creoles.” These were people who were of Spanish descent but who had been born in the colonies. The “peninsulares” who were born in Spain looked down on the creoles and discriminated against them.
Nationalism led the creoles to feel that this was unfair. They were nationalistic in the sense that they felt that their American homelands were just as good as Spain. They did not believe that the natives were equal to themselves or the peninsulares, but they did believe that they themselves were just as good as those born in Spain. This feeling of being ill-treated was much of what led them to rebel.
Thus, nationalism in the sense of pride in their place of birth helped inspire the creoles to rebel.