Srimad Bhagavatam Canto 02, Chapter 03, Text 08

SB 2.3.8

dharmartha uttama-slokam
tantuh tanvan pitrn yajet
raksa-kamah punya-janan
ojas-kamo marud-ganan
 
Translation by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
One should worship Lord Visnu or His devotee for spiritual advancement in knowledge, and for protection of heredity and advancement of a dynasty one should worship the various demigods.
 
Purport by His Divine Grace A. C. Bhaktivedanta Swami Srila Prabhupada: 
 
The path of religion entails making progress on the path of spiritual advancement, ultimately reviving the eternal relation with Lord Visnu in His impersonal effulgence, His localized Paramatma feature, and ultimately His personal feature by spiritual advancement in knowledge. And one who wants to establish a good dynasty and be happy in the progress of temporary bodily relations should take shelter of the Pitas and the demigods in other pious planets. Such different classes of worshipers of different demigods may ultimately reach the respective planets of those demigods within the universe, but he who reaches the spiritual planets in the brahmajyoti achieves the highest perfection.
 
Srimad Bhagavatam Canto 02, Chapter 03, Text 02-07
Srimad Bhagavatam Canto 02, Chapter 03, Text 09