PurposeThe purpose of this study is to examine the effect of country- and firm-specific factors on foreign investment in Pakistan.Design/methodology/approachThis study uses time-series data for country-level determinants and uses panel data for 100 listed non-financial companies selected based on market capitalisation from 2005 to 2015.FindingsFindings suggest that the stock market returns and liquidity of the country significantly positively influence the foreign portfolio investment (FPI) in Pakistan. Whereas, economic growth surprisingly is negatively related to foreign portfolio investment. In addition, findings reveal that firm size, financial leverage, dividend yield and global depositary receipts (GDR) have a positive impact on the total foreign investment at firm level. Further, foreign institutional investors prefer to invest in those firms that are large, pay high dividends and issue GDR. Furthermore, findings suggest that foreign direct investors tend to invest in firms that are financially leveraged and have low capital gain yield.Practical implicationsAt the country level, this study recommends that stock market performance, economic growth and foreign reserves of the country should be maintained and improved to attract FPI. At the firm level, this study recommends issuance of global depositary receipts and high dividend payouts for those firms that are interested in institutional investment in Pakistan.Originality/valueTo the best of authors' knowledge, this study is the first that examines the effect of firm-level factors along with country-level factors on foreign investment in Pakistan.