Hi there,
It's usually a combination of both. The strength and relevance of the domain as a whole is important and usually, the search engines will measure this through a combination of links pointing at the domain and the overall quality of all pages on your website. For example, if you have 1000 pages and half of them are low quality, then that may affect the strength of the domain as a whole.
Generally, individual pages are what matters when it comes to specific keyword searches because the search engines want to provide the best result and a result is an individual page. So if your page is most relevant and best quality, it has a good chance of ranking for that keyword. However, if it's a competitive keyword (many are these days!) then the search engine will also look at the strength of the domain as a whole to see if it should rank your page.
I hope that helps and makes sense!
Paddy