A novel dual-functional inerter-based damper, called electromagnetic tuned inerter damper (ETID), is presented in this paper for vibration control and energy harvesting. To evaluate the effectiveness of the ETID, the simplified model of ETID coupled with a single-degree-of-freedom (SDOF) structure has been established. The H2 optimal design of the ETID-SDOF system has been conducted, whose goal is to minimize the value of the root mean square (RMS) of the displacement and absolute acceleration of the primary structure. The analytical solutions of the dimensionless tuning parameters of the undamped ETID-SDOF system have been derived. The control performance and robustness for the undamped SDOF system with ETID have been evaluated via numerical study compared with the undamped SDOF system with the tuned mass damper (TMD) system. The impact of the structural damping on the tuning parameters and performance indexes has also been investigated. Later, the performance of the optimal ETID-SDOF system has been evaluated in the time domain via real earthquake excitations. The results show that the proposed optimal ETID-SDOF system can sufficiently reduce the structural displacement or absolute acceleration and simultaneously harvest vibrational energy.