You can use
tile_set_background() as well, but that would require you to loop through each tile; which is not the fastest approach. Besides, I have personally always worked with layers to achieve that, so I usually spam people with that suggestion. ^^"
Either way, you would have to rearrange tiles of both the tilesets (backgrounds) in such a way that each tile position corresponds to the same thing. For instance, tile at the top-left corner (tile at the (0,0)th position) in both the tilesets would represet a brick and the (5,6)th tile in both of them would represent mud; and so on. Hope that explains what I mean by "rearranging" the tiles. After that is done, you need to make sure that tiles of both the tilesets are of the same size, or you might get inconsistent results.
Now you would require a list of all the tiles that you want to take into account. If you don't use tiles for something other than crafting the environment, use
tile_get_ids() to get an array populated with the tile IDs. If that is not the case, use
tile_get_ids_at_depth() to get the array, populated with tile IDs of the depth layer that you'd want to reserve for the environment. I'd use the latter, because habits. ^^"
Code:
var tiles = tile_get_ids_at_depth(900);
for (var i = 0; i < array_length_1d(tiles); i += 1) {
tile_set_background(tiles[i], bg_Grasstileset);
}