"DBRS considers structural improvements in the Spanish economy have strengthened the prospects for sustainable growth," it said in a statement. "Against this background, DBRS anticipates that higher revenues and expenditure control will allow the Spanish government to continue to reduce its fiscal deficit in coming years."
Another ratings agency, Fitch, had upgraded Madrid's sovereign debt rating in January while S&P Global followed suit last month.
DBRS said it believed Spain's "strong economic and fiscal performance" would continue "largely unaffected" by political tensions in Catalonia over the wealthy northeastern region's independence drive.
"The economic impact has been confined to the regional economy, and largely offset by stronger external demand," it said.
Catalonia, which was previously an autonomous region, remains under direct rule from Madrid, which was imposed after the region declared independence in October.
Spain's central bank last month increased its growth forecast for 2018 to 2.7 percent from 2.4 percent as the government plans to reduce income tax for some workers and hike wages for civil servants. It said this reduction in the tax burden would however lead to a slower drop in the public deficit this year, which it predicts will reach 2.5 percent of GDP -- still below the 3.0 percent limit set by the European Union.
Spain posted a public deficit of 3.07 percent in 2017, just below its target of 3.1 percent agreed with Brussels.
Economy Minister Roman Escolano welcomed DBRS' announcement, saying it "reinforces international recognition of the robust recovery of the Spanish economy".