To meet the ever increasing data traffic demand from Device-to-Device (D2D) users, more mobile broadband bandwidth will be needed. Given the large amount of spectrum available in the unlicensed band, it is now being considered by the cellular operators as a complementary tool to augment their service offering. However, due to the uncontrollable interference from collocated WiFi networks, the available bandwidth for the D2D users cannot be guaranteed. In this paper, we introduce an approach for resource allocation to D2D users by aggregating spectrum resources from both licensed and unlicensed bands. An optimization framework that maximizes the utility functions of all the D2D pairs while minimizing the overall energy consumption when transmitting on licensed and unlicensed bands is proposed. Since the aforementioned spectrum and power allocation problem is NP-hard in nature, we therefore, propose a two-step framework for resource allocation to D2D pairs. In the first step, an efficient resource (LTE Resource Blocks (RBs) and unlicensed subchannels) assignment scheme is obtained by formulating a convex optimization problem, which maximizes the aggregate utility of D2D pairs while maintaining fixed transmission power on all the RBs/unlicensed subchannels. In the next step, a non-linear programming problem that maximizes the aggregate utility over sum energy consumption is formulated based on the spectrum resource allocation results obtained from the previous step. The optimization problem determines the transmission power on all the allocated RBs/subchannels by using primal-dual decomposition theory and the gradient update method. As a result of this, we observe that a user and the resource preferences can be considered while performing resource allocation. We further observe that in a network comprising of two category of users (viz., one who have subscribed to real time Quality of Service (QoS) services and second who have subscribed to Best Effort (BE) services), the proposed resource allocation scheme gives priority to QoS services when allocating resources. Extensive simulations and comparison with various benchmark schemes show that aggregating both licensed and unlicensed resources indeed improves the utility of the D2D pairs. © 2019 Elsevier B.V.