This psalm is without the name of its author, as the Syriac interpreter observes. Aben Ezra, on Ps 106:47, says, that one of the wise men of Egypt (perhaps Maimonides) was of opinion that it was written in the time of the judges, when there was no king in Israel; and another, he says, thought it was written in Babylon: but he was of opinion it was wrote under the inspiration of the Holy Ghost, or by a prophetic spirit, concerning their present captivity; and so Kimchi. The petition in Ps 106:47, "gather us from among the Heathen", has led most interpreters to conclude that it was written either in the Babylonish captivity, or, as some, in the times of Antiochus: but by comparing it with 1Ch 16:7, it appears that it was written by David, at the time of the bringing up of the ark to Zion; since the first and two last verses of it are there expressly mentioned, in the psalm he gave Asaph to sing on that occasion, Ps 106:34-36, who therein might have respect to the Israelites that had been taken captive by some of their neighbours, as the Philistines, and still retained; though there is no difficulty in supposing that David, under a prophetic spirit, foresaw future captivities, and represents those that were in them. As the preceding psalm treats of the mercies and favours God bestowed upon Israel, this of their sins and provocations amidst those blessings, and of the goodness of God unto them; that notwithstanding he did not destroy them from being a people; for which they had reason to be thankful.